cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MKatsanevas
Frequent Visitor

Running Sum on If statement in Power BI Table

Hello. I have a measure that is using an if statement for the result by month. I need a running sum of that monthly column

MonthlyCommEarnedCalc =
IF( [% Month Target] >1.0,
[Monthly Comm],
[MonthlyCommCalc]
)
I have tried several different ways to create the running sum and cant get it to work. Any help would be appreciated.
The calculation below is giving me the same value as the original measure.
RunSum Month Comm Earned =
CALCULATE(
[MonthlyCommEarnedCalc],
FILTER(
ALLSELECTED(Transactions[Fiscal Month]),
MIN(Transactions[Fiscal Month start Date]) <= MAX(Transactions[Fiscal Month End Date])
MKatsanevas_0-1630524479028.png

 

))
1 ACCEPTED SOLUTION
MrSujay
Resolver II
Resolver II

Hi @MKatsanevas 

First, create the month column in numeric form.

To calculate the running total for another measure then just add that measure code ( if block ) into your running total code.

example code :

Monthly Comm running sum = 
VAR month = MAX(Transactions[Fiscal Month])
VAR result =  CALCULATE(  
                         [MonthlyCommEarnedCalc],// OR Put if condtion measure code here
                         Transactions[Fiscal Month] <= month,
                         ALLSELECTED(Transactions)
                         )
 
Return result

 
check this tutorial :
https://www.youtube.com/watch?v=4gf3eueRD_g


Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

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
MrSujay
Resolver II
Resolver II

Hi @MKatsanevas 

First, create the month column in numeric form.

To calculate the running total for another measure then just add that measure code ( if block ) into your running total code.

example code :

Monthly Comm running sum = 
VAR month = MAX(Transactions[Fiscal Month])
VAR result =  CALCULATE(  
                         [MonthlyCommEarnedCalc],// OR Put if condtion measure code here
                         Transactions[Fiscal Month] <= month,
                         ALLSELECTED(Transactions)
                         )
 
Return result

 
check this tutorial :
https://www.youtube.com/watch?v=4gf3eueRD_g


Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

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

MKatsanevas
Frequent Visitor

Thanks. Im new to Dax and im not sure exactly how to proceed. 

@MKatsanevas What happens if you change your ALLSELECTED to ALL?


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

Greg_Deckler
Super User
Super User

@MKatsanevas This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
SumScoreMeasure = SUMX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors