Forum Discussion
dynamic conditinal formatting based on mtrix condition
- Anonymous7 years ago
Hi there,
This one works and I did conditional formatting based on that
Formatting =VAR Percentage = [Actual Vs Budget]VAR CheckExpand = Not(HASONEVALUE(GLedger[Month Name])) ||Not(HASONEVALUE(GLedger[GL_ACCT_TYPE])) || NOT(HASONEVALUE(GLedger[DD]))RETURNIf(CheckExpand = TRUE(),Percentage,0)ThanksOded Dror - 7 years ago
Hi Anonymous ,
Glad I could give some pointers to get the solution don't forget to mark your result as the answer for this post to help others.
Regards,
MFelix
Hi Anonymous ,
I made a small example with the following setup:
| Cat | SubCat | Value |
| A | A | 100 |
| A | B | 200 |
| B | A | 100 |
| B | B | 100 |
| C | A | 20 |
| C | B | 50 |
Created the following measure:
Formatting = IF(NOT(HASONEVALUE('Table'[SubCat]) );"red")
Then made the condittional formating on values:
Two remarks:
- Use the NOT so that the expanded would not need to have the hex coding
- You can change the "Red" by the HEX code something like "#FF0000"
Be aware that when you expand one of the categories on the matrix table the condittional formatting will not aplly to any subtotals (this is behaviour on PBI not error).
Regards,
MFelix
Hi there,
You are checking the condition of the matrix if is expaned or collapsed that's one thing
The second thing is if it collapsed (then check) and subToal is over Budget below 10% then yellow over 10% red
And when the matrix is expanded don't show the background color, most likely I need to add calculate value too
to the IF statement, can you incorporate multiple IF statements and show me how to achive that? I need help on that.
Thanks,
Oded dror
- MFelix7 years agoSuper User
Hi Anonymous ,
You can use a SWITCH function that evaluates an expression against a list of values and returns one of multiple possible result expressions.
Formatting = VAR Percentage = ( SUM ( 'Table'[Value] ) / SUM ( 'Table'[Target] ) ) - 1 VAR CheckExpand = NOT ( HASONEVALUE ( 'Table'[SubCat] ) ) RETURN SWITCH ( TRUE (); CheckExpand && Percentage < 0,1; "Yellow"; CheckExpand && Percentage > 0,1; "Red" )You can change the Percentage formula by the one you think is more suitable to your calculations.
Regards,
MFelix
- Anonymous7 years agoNot applicable
Hi there,
this is my calculation - no error there but when I put this measure in my marrix I'm getting this error (see below)
Formatting =
VAR Percentage =
Divide(((Sum('ActualVsBudget'[Activity_YTD]) - Sum(ActualVsBudget[BUD_YTD]))) , Sum(ActualVsBudget[BUD_YTD]) )
VAR CheckExpand =
NOT ( HASONEVALUE ( 'GLedger'[Account]) )
RETURN
SWITCH (
TRUE(),
CheckExpand
&& Percentage < 0,0.1, "Yellow",
CheckExpand
&& Percentage > 0,0.1, "Red"
)
Error Message:
MdxScript(Model) (34, 31) Calculation error in measure 'GLedger'[Formatting]:
Function 'SWITCH' does not support comparing values of type True/False with values of type Number.
Consider using the VALUE or FORMAT function to convert one of the values.Thanks,Oded Dror- Anonymous7 years agoNot applicable
Hi there,
I modify the measure and got it to work but it still showing flags when th ematrix is expandad
Formatting =VAR Percentage = [Actual Vs Budget]VAR CheckExpand =NOT ( HASONEVALUE ( 'GLedger'[DD]) )RETURNSWITCH (TRUE(),CheckExpand&& Percentage >= 0.0 && Percentage <= 0.10, UNICHAR(128077),CheckExpand&& Percentage > 0.10 && Percentage < 1.0, UNICHAR(128681))Thanks,Oded Dror