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.
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?
Solved! Go to 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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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
To learn more about Power BI, follow me on Twitter or subscribe 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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
@mahoneypat I've been "plugging and playing" and got the below to work for me.
Glad to hear it. Please mark one or both as the solution.
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
98 | |
78 | |
66 | |
53 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |