cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SirBI
New Member

Measures with Total

SirBI_0-1623532110468.png

I have the above chart. I have a KPI light (conditional formatted column, bottom of page) 

 

       COLOR_IND_FORMAT =
        SWITCH(
        TRUE(),
        Daily[Check type] = "SAM" && Daily[PRCNT_DIFF] >=16, "RED",
       Daily[Check type] = "SAM" && Daily[PRCNT_DIFF] >=11 && AutoDialerDaily[PRCNT_DIFF] <=15 , "YELLOW",
        Daily[Check type] = "SAM" && Daily[PRCNT_DIFF] <=10, "GREEN",
       "BLACK")

 

 I want my "TOTAL" to have it's own set of conditions for the [PRCNT_DIFF], is that possible?

 

Percentage change =
VAR __BASELINE_VALUE = SUM('Daily'[PREV_CNT])
VAR __VALUE_TO_COMPARE = SUM('Daily'[CURR_CNT])
RETURN
    IF(
        NOT ISBLANK(__VALUE_TO_COMPARE),
        DIVIDE(__VALUE_TO_COMPARE - __BASELINE_VALUE, __BASELINE_VALUE)
    )
1 ACCEPTED SOLUTION

I'm not sure which are columns and which are measures (the convention is that column include the table and measures do not), but it would look something like this.

 

COLOR_IND_FORMAT =
VAR statecount =
    COUNTROWS ( DISTINCT ( Daily[State] ) )
VAR checktype =
    MIN ( Daily[Check type] ) //assumes this is a column
VAR prcntdiff = [PRCNT_DIFF] //assumes this is a measure. calculated as a variable to improve performance
VAR __BASELINE_VALUE =
    SUM ( 'Daily'[PREV_CNT] )
VAR __VALUE_TO_COMPARE =
    SUM ( 'Daily'[CURR_CNT] )
VAR totalvalue =
    DIVIDE ( __VALUE_TO_COMPARE - __BASELINE_VALUE__BASELINE_VALUE )
VAR result =
    SWITCH (
        TRUE (),
        statecount > 1
            && totalvalue > 50"Green",
        statecount > 1
            && totalvalue <= 50"Red",
        checktype = "SAM"
            && prcntdiff >= 16"RED",
        checktype = "SAM"
            && prcntdiff >= 11
            && AutoDialerDaily[PRCNT_DIFF] <= 15"YELLOW",
        //not sure if autodialer is a measure or column. if column, it will need to be aggregated
        checktype = "SAM"
            && prcntdiff <= 10"GREEN",
        "BLACK"
    )
RETURN
    result
//result made as a variable for easier troubleshooting

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
mahoneypat
Super User IV
Super User IV

You can use HASONEVALUE on your State column in your expression to check if the context is one of your rows or the total row and have different expression based on that.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat could you help me out with the syntax? I'm working on it but can't seem to get this correct. 

I'm not sure which are columns and which are measures (the convention is that column include the table and measures do not), but it would look something like this.

 

COLOR_IND_FORMAT =
VAR statecount =
    COUNTROWS ( DISTINCT ( Daily[State] ) )
VAR checktype =
    MIN ( Daily[Check type] ) //assumes this is a column
VAR prcntdiff = [PRCNT_DIFF] //assumes this is a measure. calculated as a variable to improve performance
VAR __BASELINE_VALUE =
    SUM ( 'Daily'[PREV_CNT] )
VAR __VALUE_TO_COMPARE =
    SUM ( 'Daily'[CURR_CNT] )
VAR totalvalue =
    DIVIDE ( __VALUE_TO_COMPARE - __BASELINE_VALUE__BASELINE_VALUE )
VAR result =
    SWITCH (
        TRUE (),
        statecount > 1
            && totalvalue > 50"Green",
        statecount > 1
            && totalvalue <= 50"Red",
        checktype = "SAM"
            && prcntdiff >= 16"RED",
        checktype = "SAM"
            && prcntdiff >= 11
            && AutoDialerDaily[PRCNT_DIFF] <= 15"YELLOW",
        //not sure if autodialer is a measure or column. if column, it will need to be aggregated
        checktype = "SAM"
            && prcntdiff <= 10"GREEN",
        "BLACK"
    )
RETURN
    result
//result made as a variable for easier troubleshooting

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

@mahoneypat I've been "plugging and playing" and got the below to work for me. 

 

COLOR_IND_FORMAT3 =
VAR statecount = COUNTROWS (DISTINCT(AutoDialerDaily[State]))
VAR checktype = MIN (AutoDialerDaily[Check type])
VAR prcntdiff = MIN (AutoDialerDaily[PRCNT_DIFF])
VAR result =
SWITCH (
TRUE (),
statecount > 1
&& checktype = "STATE AM" && prcntdiff >=16, "RED",
statecount > 1
&& checktype = "STATE AM" && prcntdiff>=11 && prcntdiff <=15 , "YELLOW",
statecount > 1
&& checktype = "STATE AM" && prcntdiff <=10, "ORANGE",
//Individual State calculations below
checktype = "STATE AM" && prcntdiff >=16, "RED",
checktype = "STATE AM" && prcntdiff >=11 && prcntdiff <=15 , "YELLOW",
checktype = "STATE AM" && prcntdiff <=10, "PINK",
"BLACK")
RETURN
result

Glad to hear it.  Please mark one or both as the solution.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors