Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
NanDeb
Helper I
Helper I

DAX HELP - Back filtering part table based on percentage of total sales

 
 

I am looking for some help "back filtering" sales. 

The requirement to to retunr the Top X products that contibute to 80% of the total sales value.  I am guessing that I could use a combination of a cumulative total and rankx somehow. 

I have a the following tables in my model, 

FactSales

DimDate

DimProduct

DimCustomer


 

Any help greatfully received 

1 ACCEPTED SOLUTION

Hi @NanDeb ,

 

Please create following measure:

cumulative_sales(80%) = 
var cumulative_sales = CALCULATE(SUM('Table'[VALUE]),FILTER(ALL('Table'),'Table'[TaxDate] <= SELECTEDVALUE('Table'[TaxDate])))
var total_sales = CALCULATE(SUM('Table'[VALUE]),ALL('Table'))
return
IF(cumulative_sales <= total_sales * 0.8, cumulative_sales)

 

I think this is the result you want:

vyadongfmsft_0-1670823699186.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
NanDeb
Helper I
Helper I

@v-yadongf-msft

 

to start with I would like returned a table of all the products and their cumulative sales.

 

If possible I would then also like to exclude the lower ranking sales after cumulative value of 80% of total sales value is reached

EG, 

 

Total Sale Value = £800,000
80% Sales Value = £640,000

I want to return something like this: 

Product IDRank

Total Sale Value

Cumulative
AAA1£90,000£80,000
BBB2£85,000£175,000
CCC3£80,000£255,000
DDD4£75,000£330,000
EEE5£70,000£400,000
FFF6£65,000£465,000
GGG7£60,000£525,000
HHH8£55,000£580,000
III9£50,000£620,000
JJJ10£45,000NOT INCLUDED If possible

 

Is there anyway of achieving this in DAX

Hi @NanDeb ,

 

Please create following measure:

cumulative_sales(80%) = 
var cumulative_sales = CALCULATE(SUM('Table'[VALUE]),FILTER(ALL('Table'),'Table'[TaxDate] <= SELECTEDVALUE('Table'[TaxDate])))
var total_sales = CALCULATE(SUM('Table'[VALUE]),ALL('Table'))
return
IF(cumulative_sales <= total_sales * 0.8, cumulative_sales)

 

I think this is the result you want:

vyadongfmsft_0-1670823699186.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yadongf-msft
Community Support
Community Support

Hi @NanDeb ,

 

In order to better understanding your demands and give the right solution, could you please tell me what's your expected output?

 

Thanks for your efforts & time in advance.

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

NanDeb
Helper I
Helper I

 


A simplied example of by data here: 

TaxDateCustIDPARTIDVALUE
01/01/2022ZZZ123345356.1
02/01/2022BBB2452468.87
03/01/2022GGG17612479.56
04/01/2022ZZZ1231358.8
05/01/2022AAA5232357.45
06/01/2022AAA987196246.7
07/01/2022CCC2453463.87
08/01/2022VVV1673666.67
09/01/2022BBB276234.98
10/01/2022ZZZ1122352.87
11/01/2022CCC9126345.56
12/01/2022EEE65634653.78

 

IdCustID
1AAA5
2AAA9
3BBB2
4CCC2
5CCC9
6EEE9
7GGG1
8VVV1
9ZZZ1

 

IdPartID
123
245
376
487
567
612
756

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.