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

Sumx and row context

Hi 

 

Suppose i've got a sales table with detail about products etc.. and 3 years (2018 / 2019 / 2020)

 

Here's my issue, i need to perform that kind of calculation :

 

   1 - do a classic sumx on my dataset, let's say sum by year of QTTE by PRICE

 

2018 - 10 000

2019 - 11 500

2020 - 20 000

 

   2 - then divide these sumx measure by the value i got for 2018

 

2018 - 1      (10 000 / 10 000)

2019 - 1.15

2020 - 2

 

Because of the sumx that stick me with the row context, the classic   CALCULATE(result ; year = 2018)    doesn't work.

 

I hope i'm clear enough.

 

Thank you guys

 

Stephane

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous not sure what the issue or what is not working

 

following measures will work

 

Total Sum = SUM( Table[Column] )

Sum 2018 = CALCULATE ( [Total Sum], All(Table), Table[Year] = 2018 )

Ratio = DIVIDE( [Total Sum], [Sum 2018] )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@Anonymous not sure what the issue or what is not working

 

following measures will work

 

Total Sum = SUM( Table[Column] )

Sum 2018 = CALCULATE ( [Total Sum], All(Table), Table[Year] = 2018 )

Ratio = DIVIDE( [Total Sum], [Sum 2018] )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi @parry2k 

 

i found the problem :

 

i was using VARIABLES and that was disrupting my calculations.

 

----

WRONG_RESULT =

     VAR Total Sum = SUM( Table[Column] )

     VAR Sum 2018 = CALCULATE ( [Total Sum], All(Table), Table[Year] = 2018 )

     VAR Result = DIVIDE( [Total Sum], [Sum 2018] )

     RETURN Result

 

The [Sum 2018] wasn't correct.

 

CORRECT_RESULT =

     VAR Sum 2018 = CALCULATE ( SUM( Table[Column] ), All(Table), Table[Year] = 2018 )

     VAR Result = DIVIDE( [Total Sum], [Sum 2018] )

     RETURN Result

 

I tried to upload my dummy.pbix file but i didn't find where to attach it...

Anonymous
Not applicable

mmmh i should have tried this before asking you : building a dummy pbix to show you my issue.
 
While doing it i realize that my issue does not come from the formula as the CALCULATE(sumx;filter) is working fine indeed.
 
Well now i know i need to focus elsewhere to debug the **bleep** thing.
 
Thanks for your help !

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.