How to Create Awesome Business Central Data Analysis

In my last post, 3 Thing to Know About Dynamics 365 Business Central, one of the things I discussed was how to connect Power BI to Dynamics 365 Business Central. The Power BI Content Pack has several reports. Two of those are “Item Sales Dashboard” and “Customer Sales Dashboard” (screenshots below). These are a good start but enhance our data analysis by connecting to our data and transforming it and adding some DAX measures.

Item Sales Dashboard

Customer Sales Dashboard

Creating our Visuals

First some basics, before we connect to our Dynamics 365 Business Central data. We need a Power BI model with a good date dimension table and there is no better place to start then with #sqlbi.com DAX Date template. You can get it here: https://www.sqlbi.com/tools/dax-date-template/. Alberto and Marco do a great job teaching all things DAX, so explore around while you’re on their web site.

Now let’s add Dynamics 365 Business Central as a data source in Power BI Desktop

  1. In Power BI Desktop, in the left navigation pane, choose Get Data.
  2. In the Get Data window, choose Online Services, choose Microsoft Dynamics 365 Business Central, and then choose the Connect button.Get Data connect login to Business Central
  3. Power BI displays a wizard that will guide you through the connection process. You will be prompted to sign into the service. Select Sign in and choose the account you would like to sign in as. This should be the same account you sign into Dynamics 365 Business Central with.Business Central Login
  4. Choose the Connect button to continue. The Power BI wizard shows a list of Microsoft Business Central companies and data sources. These data source represent all the web services that you have published from each company in Microsoft Dynamics 365 Business Central.Connect screen
  5. Alternatively, create a new web service URL in Dynamics 365 Business Central by using the Create Data Set action in the Web Services page, using the Set Up Reporting Assisted Setup guide, or by choosing the Edit in Excel action in any lists.
  6. Specify the data you want to add to your data model, and then choose the Load button.
  7. Repeat the previous steps to add additional Microsoft Dynamics 365 Business Central, or other data, to your Power BI data model.

Once the data is loaded it will appear in the right navigation on the page. At this point, you have successfully connected to your Microsoft Dynamics 365 Business Central data and are ready to begin building your Power BI report.

Before building your report, we recommend that you import the Microsoft Dynamics 365 Business Central theme file. The theme file will create a color palette so that you can build reports with the same color styling as the Microsoft Dynamics 365 Business Central content packs without requiring you to define custom colors for each visual. You can find the download for the json theme file here: https://community.powerbi.com/t5/Themes-Gallery/Microsoft-Dynamics-365-Business-Central/m-p/385875

Business Central available data

Here are the data tables we are going to import:

  • InventoryItems
  • InventoryTransactions
  • ItemLedgerEntries
  • ItemSalesandProfits

After importing the InventoryItems data we need to make the following changes.

  1. Rename the “No” column to “Item No”
  2. Remove several columns listed below in the M Code.
  3. Add a custom column to calculate Unit Profit

Here is the M code to help you with the transformations. You will need to change the source information to match your environment.

    Source = Dynamics365BusinessCentral.Contents(null),
    #"CRONUS USA, Inc." = Source{[Name="CRONUS USA, Inc."]}[Data],
    InventoryItems_table = #"CRONUS USA, Inc."{[Name="InventoryItems",Signature="table"]}[Data],
    #"Renamed Columns" = Table.RenameColumns(InventoryItems_table,{{"No", "Item No"}}),
    #"Trimmed Text" = Table.TransformColumns(#"Renamed Columns",{{"Description", Text.Trim, type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Trimmed Text",{"Created_From_Nonstock_Item", "Substitutes_Exist", "Stockkeeping_Unit_Exists", "Assembly_BOM", "Production_BOM_No", "Routing_No", "Shelf_No", "Cost_is_Adjusted", "Standard_Cost", "Last_Direct_Cost", "Price_Profit_Calculation", "VAT_Prod_Posting_Group", "Item_Disc_Group", "Tariff_No", "Search_Description", "Overhead_Rate", "Indirect_Cost_Percent", "Blocked", "Last_Date_Modified", "Manufacturing_Policy", "Flushing_Method", "Assembly_Policy", "Default_Deferral_Template_Code", "Global_Dimension_1_Filter", "Global_Dimension_2_Filter", "Location_Filter", "Drop_Shipment_Filter", "Variant_Filter", "Lot_No_Filter", "Serial_No_Filter", "ETag", "Item_Tracking_Code"}),
    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Unit Profit", each [Unit_Price]-[Unit_Cost]),
    #"Replaced Value" = Table.ReplaceValue(#"Added Custom","","KIT",Replacer.ReplaceValue,{"Item_Category_Code"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Replaced Value",{{"Gen_Prod_Posting_Group", "Channel Name"}, {"Item_Category_Code", "Item Category"}, {"Base_Unit_of_Measure", "Unit of Measure"}, {"Profit_Percent", "Profit Percent"}, {"Inventory", "Inventory Qty"}, {"Unit_Cost", "Unit Cost"}, {"Unit_Price", "Unit Price"}})
in
    #"Renamed Columns1"

Now let’s duplicate the Inventory Transactions data and make some changes to it.

  1. Right click on the InventoryTransactions table and select “Duplicate”
  2. Rename the duplicated table to Inventory Amounts
  3. Remove several columns. They are listed below in the M code
  4. Select the Transform tab and then the Group By icon on the menu
  5. Select the advanced option and group the data by Posting_Date and Item_No and sum the Inventory Quantity
    Group By screen
    Here is the M code to help you with the transformations. You will need to change the source information to match your environment.
    Source = Dynamics365BusinessCentral.Contents(null),
    #"CRONUS USA, Inc." = Source{[Name="CRONUS USA, Inc."]}[Data],
    InventoryTransactions_table = #"CRONUS USA, Inc."{[Name="InventoryTransactions",Signature="table"]}[Data],
    #"Renamed Columns" = Table.RenameColumns(InventoryTransactions_table,{{"Document_No", "Document No"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"Expiration_Date", "ETag", "Document_Type", "Document No", "Document_Line_No", "Variant_Code", "Description", "Return_Reason_Code", "Global_Dimension_1_Code", "Global_Dimension_2_Code", "Serial_No", "Lot_No", "Cost_Amount_Non_Invtbl", "Cost_Amount_Expected_ACY", "Cost_Amount_Actual_ACY", "Cost_Amount_Non_Invtbl_ACY", "Completely_Invoiced", "Open", "Drop_Shipment", "Assemble_to_Order", "Applied_Entry_to_Adjust", "Order_Type", "Order_No", "Order_Line_No", "Prod_Order_Comp_Line_No", "Job_No", "Job_Task_No", "Dimension_Set_ID", "Item_No_Link", "Job_No_Link", "Job_Task_No_Link", "Cost_Amount_Expected", "Reserved_Quantity", "Qty_per_Unit_of_Measure", "Sales_Amount_Expected", "Entry_No", "Location_Code", "Shipped_Qty_Not_Returned", "Sales_Amount_Actual", "Cost_Amount_Actual", "Invoiced_Quantity"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"Remaining_Quantity", "Inventory_Quantity"}}),
    #"Grouped Rows" = Table.Group(#"Renamed Columns1", {"Posting_Date", "Item_No"}, {{"InvQty", each List.Sum([Inventory_Quantity]), type number}}),
    #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Posting_Date", Order.Ascending}})
in
    #"Sorted Rows"

Creating the DAX for our Visuals

On the Inventory Performance report, I’ve added the ability to segment my quantity sold by growth rate over the previous period selected. Here are the steps I used to add the changes to the report.

  1. First, I clicked on the “Enter Data” icon from the Home tab in Power BI Desktop and entered the following information and named the table “Growth Segments”.
  2. The DAX measures needed for our visuals:

Total Qty Sold CY = SUM('Inventory Amounts'[InvQty])

CALCULATE( 
    [Total Qty Sold CY], 
    SAMEPERIODLASTYEAR( 'Date'[Date] ))

Qty Sold Growth = DIVIDE([Total Qty Sold CY],[Total Qty Sold LY],0)-1

    CALCULATE (
    [Total Qty Sold CY],
    FILTER (
        VALUES ( 'Inventory Items'[Item No] ),
        COUNTROWS (
            FILTER (
                'Growth Segments',
                [Qty Sold Growth] >= 'Growth Segments'[Min]
                    && [Qty Sold Growth]  0))
InventoryAvgAmt = SUM('Inventory Amounts'[Inventory Cost])/DISTINCTCOUNT('Inventory Amounts'[Posting_Date])
COGS_Actual = ABS(SUM('Inventory Transactions'[Cost_Amount_Actual]))

Turnover = [COGS_Actual]/[InventoryAvgAmt]

Inventory period = 365/[Turnover]

With all of the DAX Measures created we put them all together to create the below Inventory Performance report that now gives us the ability to track KPI to goals, see Sales and inventory quantity trends over time and visualize quantity sold per growth group compared to last period.

Inventory Performance Report

In my next post, I will create the Customer Sales Performance report to complete the enhance of the Business Central Sales Content pack. Until then, go sign up for a free trial of Dynamics 365 Business Central at https://trials.dynamics.com/. You just need to provide your work email address and Phone Number. Dynamics 365 Business Central is an all-in-one business management solution that helps organizations streamline business processes, improve customer interactions and enable growth by offering:

  • Business without silos. Unify business and boost efficiency with automated tasks and workflows—all from within familiar Office tools like Outlook, Word, and Excel.
  • Actionable insights. Achieve greater outcomes and gain a complete view across the business with connected data, business analytics, and guidance delivered by Microsoft’s leading intelligent technologies.
  • Solutions built to evolve. Start quickly, grow and adapt in real time with a flexible platform that makes it easy to extend beyond Business Central based on evolving business needs.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s