Forum Discussion

m_wex's avatar
m_wex
Icon for Helper I rankHelper I
2 years ago
Solved

Stuck on %of Total Problem

I am working with grouping previous year customer sales into small, medium, and large buckets. A Customer size table has been created for the grouping:

With a page filter for small, medium, and large sales can be displayed for the selected size.

The dax formula to calculate sales is:

 

CY Customer Sales by Grouping  4 Test =
Calculate([CY Total Sales],
filter(values(Sales[Sold-To Party]),  
    countrows(
        Filter('Customer Size Table',
        [PY Total Sales]>='Customer Size Table'[Min]&&
        [PY Total Sales]<= 'Customer Size Table'[Max]))>0))
 
The problem that I am having is that I am trying to write a DAX for % of Total sales which compares the size selected to ALL sizes.
The formula that I have is below but is not working. I understand that the size filter has to be removed from one portion of the DAX but the solution is escaping me.
 
This does not work: % of Total Customer Size Test 4 = divide([CY Customer Sales by Grouping  4 Test],calculate([CY Customer Sales by Grouping  4 Test]),all('Customer Size Table'[Size]))
 
Any help would be greatly appreciated.
 
 
  • Hi m_wex 

    You can perform a flexible % analysis using Dax, and there are many ways to produce your required output and one of them is as follows.  (I've created a dummy sales data in order to demonstrate in this example). 

    Assuming that your Sold-To-Party information is not repetitive (i.e., unique), you can create a calculated column to pre-calculate classification into sales size groupings for each sold-to-party.

     

    Then create a relationship between your size dimension table and your fact table with the sales figures and sales size grouping for each sold-to-party.

    Then, create an intermediary measure like below which ignores filter of the size dimention by using all(Size) table, and divide the sales measure with this one to get the % of each size grouping over the total sales amounts. 

    You can do the similar calculation in many different ways, but the above one is breaking down the steps for simplicity purposes. 

    I attach an example pbix file, too.  

    Best regards,

     

     

1 Reply

  • Hi m_wex 

    You can perform a flexible % analysis using Dax, and there are many ways to produce your required output and one of them is as follows.  (I've created a dummy sales data in order to demonstrate in this example). 

    Assuming that your Sold-To-Party information is not repetitive (i.e., unique), you can create a calculated column to pre-calculate classification into sales size groupings for each sold-to-party.

     

    Then create a relationship between your size dimension table and your fact table with the sales figures and sales size grouping for each sold-to-party.

    Then, create an intermediary measure like below which ignores filter of the size dimention by using all(Size) table, and divide the sales measure with this one to get the % of each size grouping over the total sales amounts. 

    You can do the similar calculation in many different ways, but the above one is breaking down the steps for simplicity purposes. 

    I attach an example pbix file, too.  

    Best regards,