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
Anonymous
Not applicable

DAX Formula help to achieve Cumulative

Dear Experts

 

I would like to achieve the below "% Contribution (reverse)" and "Cumulative" based on the value in my previous column. These 2 columns should be dynamic (meaning, if I remove "Prod C" from the report the columns should adjust calculations accordingly.

Please advise how to achieve this.

 

cumilative.JPG

 

Thanks in advance
MAHAD

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

Measure:

% Contribution = 
DIVIDE(SUM('Table'[Qty]),CALCULATE(SUM('Table'[Qty]),ALL('Table')))

vzhangti_0-1657613466494.png

Add the index column to the power query.

Index2 = MAXX(ALL('table'),[index])-MAX([Index])+1

vzhangti_1-1657613534186.png

% Contribution (reverse) = 
CALCULATE([% Contribution],FILTER(ALL('Table'),[Index2]=SELECTEDVALUE('Table'[Index])))
Cumulative = 
CALCULATE(SUMX('Table',[% Contribution (reverse)]),FILTER(ALL('Table'),[Index]<=SELECTEDVALUE('Table'[Index])))

vzhangti_2-1657613621819.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

Measure:

% Contribution = 
DIVIDE(SUM('Table'[Qty]),CALCULATE(SUM('Table'[Qty]),ALL('Table')))

vzhangti_0-1657613466494.png

Add the index column to the power query.

Index2 = MAXX(ALL('table'),[index])-MAX([Index])+1

vzhangti_1-1657613534186.png

% Contribution (reverse) = 
CALCULATE([% Contribution],FILTER(ALL('Table'),[Index2]=SELECTEDVALUE('Table'[Index])))
Cumulative = 
CALCULATE(SUMX('Table',[% Contribution (reverse)]),FILTER(ALL('Table'),[Index]<=SELECTEDVALUE('Table'[Index])))

vzhangti_2-1657613621819.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Anonymous
Not applicable

Hi Amit

 

I'm getting the below error for both the formulas.

"Too many arguments were passed to the SUM function. The maximum argument count for the function is 1."

Please can you check and advise.

 

Thanks

Mahad

 

Anonymous
Not applicable

Check with open brackets and closing brackets of each function of your query.

Must be passing mutliple arguments to sum function.

amitchandak
Super User
Super User

@Anonymous ,  Try like

 

Cumm = CALCULATE(SUM(Sales[Qty]),filter(allselected('Table'),'Table'[Product] <=max('Table'[Product])))

 

Cumm % = divide( CALCULATE(SUM(Sales[Qty]),filter(allselected('Table'),'Table'[Product] <=max('Table'[Product]))), CALCULATE(SUM(Sales[Qty]) , allselected()) )

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.