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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Paulyeo11
Impactful Individual
Impactful Individual

How to get accumulate sales amount ?

Hi All

I have below table :-

COMPANYSALES
AAA50
BBB40
CCC30
DDD20
EEE10

Expected result :-

COMPANYSALES 
AAA5050
BBB4090
CCC30120
DDD20140
EEE10

150

 

My PBI file : https://www.dropbox.com/s/mbv8z894l551row/8020%20V003.pbix?dl=0

https://www.dropbox.com/s/mbv8z894l551row/8020%20V003.pbix?dl=0

2 ACCEPTED SOLUTIONS
v-zhenbw-msft
Community Support
Community Support

Hi @Paulyeo11 ,

 

In addition, we can use two ways to meet your requirement.

 

1. Create a measure.

 

Measure = CALCULATE( SUM('TABLE'[SALES]), FILTER( ALLSELECTED('TABLE'),'TABLE'[SALES] >=Max('TABLE'[SALES])))

 

how to 1.jpg

 

2. The second way is to add an index column firstly, then create a measure.

 

CU = CALCULATE(SUM('TABLE'[SALES]),FILTER(ALLSELECTED('TABLE'),'TABLE'[Index]<=MAX('TABLE'[Index])))

 

how to 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

Hi @Paulyeo11 ,

 

We can add a rank column in TABLE and create a measure to meet your requirement.

 

1. Create a rank column in TABLE.

 

rank = 
RANKX('TABLE',CALCULATE(SUM('TABLE'[sales]),FILTER('TABLE','TABLE'[BRAND_C]=EARLIER('TABLE'[BRAND_C]))),,ASC,Dense)

 

howto1.jpg

 

2. Then we can create a measure to get the accumulate sales.

 

acc1 = 
CALCULATE(SUM('TABLE'[sales]),FILTER(ALLSELECTED('TABLE'),'TABLE'[rank]<=MAX('TABLE'[rank])))

 

howto2.jpg

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

5 REPLIES 5
v-zhenbw-msft
Community Support
Community Support

Hi @Paulyeo11 ,

 

In addition, we can use two ways to meet your requirement.

 

1. Create a measure.

 

Measure = CALCULATE( SUM('TABLE'[SALES]), FILTER( ALLSELECTED('TABLE'),'TABLE'[SALES] >=Max('TABLE'[SALES])))

 

how to 1.jpg

 

2. The second way is to add an index column firstly, then create a measure.

 

CU = CALCULATE(SUM('TABLE'[SALES]),FILTER(ALLSELECTED('TABLE'),'TABLE'[Index]<=MAX('TABLE'[Index])))

 

how to 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Hi Sir

Thank you very much for sharing 2 script which is very powerful.

I cannot make it work for my actual PBI file :-

https://www.dropbox.com/s/plg73k6wa7brk01/SI_TDS_V012.pbix?dl=0

Hope you can help me take a look. as i get very funny number

 

Paulyeo11_0-1603098789565.png

 

Paul

Hi @Paulyeo11 ,

 

We can add a rank column in TABLE and create a measure to meet your requirement.

 

1. Create a rank column in TABLE.

 

rank = 
RANKX('TABLE',CALCULATE(SUM('TABLE'[sales]),FILTER('TABLE','TABLE'[BRAND_C]=EARLIER('TABLE'[BRAND_C]))),,ASC,Dense)

 

howto1.jpg

 

2. Then we can create a measure to get the accumulate sales.

 

acc1 = 
CALCULATE(SUM('TABLE'[sales]),FILTER(ALLSELECTED('TABLE'),'TABLE'[rank]<=MAX('TABLE'[rank])))

 

howto2.jpg

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Hi Sir

Thank you very much for your effort , it work now.

Paul

amitchandak
Super User
Super User

@Paulyeo11 ,

Try like

calculate( sum(Table[Sales]), filter( Table,[COMPANY] <=Max(Table[COMPANY])))

or

calculate( sum(Table[Sales]), filter( Table,[Sales] >=Max(Table[Sales])))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.