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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
dcrow5378
Resolver I
Resolver I

Sum Switch Values

I have a measure that looks at the Value of the current month and compares it to the previous month and applies a switch function if higher than the previous month.  I would like to be able to sum the values from this switch function.

 
Measure =
VAR PriorMonthAmt = CALCULATE( [Max FAP] , PARALLELPERIOD ( 'QM'[Report Month],-1,MONTH ) )
VAR Compare = IF ( ISBLANK ( PriorMonthAmt ), BLANK(), PriorMonthAmt - [Max FAP])
RETURN

SWITCH (
TRUE(),
Compare = 0, 0,
Compare < 0, 1,
Compare > 0, 0
)
 
Current Results: (Indicators A and B increased in Oct and Dec, Indicator C increased in Dec)
IndicatorOct 2021Nov 2021Dec 2021
A101
B101
C001
TOTAL101

 

Desired Results:  (Notice Total is summed)

IndicatorOct 2021Nov 2021Dec 2021
A101
B101
C001
TOTAL203
1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@dcrow5378  can you try this

Measure 2 = SUMX(addcolumns(summarize(qm,QM[FacilityID],QM[Indicator],QM[Report Month]),"mx",[Measure]),[mx])

 

smpa01_0-1640033629974.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

6 REPLIES 6
smpa01
Super User
Super User

@dcrow5378  can you try this

Measure 2 = SUMX(addcolumns(summarize(qm,QM[FacilityID],QM[Indicator],QM[Report Month]),"mx",[Measure]),[mx])

 

smpa01_0-1640033629974.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@smpa01 That seemed to do the trick!  I would not have got that one.  Appreciate the quick help here!

smpa01
Super User
Super User

@dcrow5378  does this give you what you need

Measure =
SUMX (
    'QM',
    VAR PriorMonthAmt =
        CALCULATE ( [Max FAP], PARALLELPERIOD ( 'QM'[Report Month], -1, MONTH ) )
    VAR Compare =
        IF ( ISBLANK ( PriorMonthAmt ), BLANK (), PriorMonthAmt - [Max FAP] )
    RETURN
        SWITCH ( TRUE (), Compare = 0, 0, Compare < 0, 1, Compare > 0, 0 )
)

 

I am gueesing QM is the table where you have the column Indicator

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@smpa01  Yes, QM is the table where I have the column indicator.
I did try something like this, and I just tried yours, and for some reason this is giving me all zeros, even though the values have increased from previous months?

@dcrow5378  sorry 'bout that. Is it kindly possible to reproduce a pbix in a small scale with identical measures for me/anyoneelse to debug?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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