Forum Discussion
dcrow5378
4 years agoResolver 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)
| Indicator | Oct 2021 | Nov 2021 | Dec 2021 |
| A | 1 | 0 | 1 |
| B | 1 | 0 | 1 |
| C | 0 | 0 | 1 |
| TOTAL | 1 | 0 | 1 |
Desired Results: (Notice Total is summed)
| Indicator | Oct 2021 | Nov 2021 | Dec 2021 |
| A | 1 | 0 | 1 |
| B | 1 | 0 | 1 |
| C | 0 | 0 | 1 |
| TOTAL | 2 | 0 | 3 |
dcrow5378 can you try this
Measure 2 = SUMX(addcolumns(summarize(qm,QM[FacilityID],QM[Indicator],QM[Report Month]),"mx",[Measure]),[mx])
6 Replies
- smpa01Community Champion
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