Forum Discussion
Combine multiple conditional formatting measures into one.
Hi,
I have created several measures which are quite similar, but redirect to a different value. Instead of creating a lot of separate measures which may influence the performance, is it possible to combine them in one?
For example below 2 measures are currently created separately, but I believe it should be possible to combine them.
Dynamic colour P-to-D = SWITCH(selectedvalue(GrossNet[GrossNet]),
"Gross", SWITCH ( TRUE() , 'Carrierkey'[YTD LY] < .95, "#D64550", "#63B14B"),
"Net", SWITCH ( TRUE() , 'Carrierkey'[YTD LY]< .97, "#D64550", "#63B14B")
)
Dynamic colour P-to-D.10 = SWITCH(selectedvalue(GrossNet[GrossNet]),
"Gross", SWITCH ( TRUE() , 'Gross/Net'[Gross/Net calculation PtoD] < .95, "#D64550", "#63B14B"),
"Net", SWITCH ( TRUE() , 'Gross/Net'[Gross/Net calculation PtoD]< .97, "#D64550", "#63B14B")
)I want to combine them because of performance and that I can use the same measures for all conditional formatting of visuals.
Thanks in advance,
Sofiën
6 Replies
- amitchandak
Super User
Anonymous as the second measure is not based on condition (like selected value) , so I doubt you can merge that
- AnonymousNot applicable
Hi Anonymous ,
Please have a try.
Create a measure.
measure= var Dynamic_colour_P-to-D.10= SWITCH(selectedvalue(GrossNet[GrossNet]), "Gross", SWITCH ( TRUE() , 'Gross/Net'[Gross/Net calculation PtoD] < .95, "#D64550", "#63B14B"), "Net", SWITCH ( TRUE() , 'Gross/Net'[Gross/Net calculation PtoD]< .97, "#D64550", "#63B14B") ) var Dynamic_colour_P-to-D= SWITCH(selectedvalue(GrossNet[GrossNet]), "Gross", SWITCH ( TRUE() , 'Carrierkey'[YTD LY] < .95, "#D64550", "#63B14B"), "Net", SWITCH ( TRUE() , 'Carrierkey'[YTD LY]< .97, "#D64550", "#63B14B") ) return IF(INSERT YOUR CONDITION HERE,Dynamic_colour_P-to-D.10,Dynamic_colour_P-to-D)If I have misunderstood your meaning, please provide you pbix file without privacy information and your desired output.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hi Anonymous,
The formula with a var statement might work well, but I doubt if I need to have an IF statement as well as there is no IF I think. I have 9 created measures as values in my dashboard with all the same format:
Dynamic colour P-to-D = SWITCH(selectedvalue(GrossNet[GrossNet]), "Gross", SWITCH ( TRUE() , <Desiredvalue> < .95, "#D64550", "#63B14B"), "Net", SWITCH ( TRUE() , <Desiredvalue> < .97, "#D64550", "#63B14B") )All these 9 separate measures are used for below values:
Kind Regards,
Sofiën
- AnonymousNot applicable
Hi Anonymous ,
When do you want to output Dynamic_colour_P-to-D.10? And when do you want to output Dynamic_colour_P-to-D? I really do not undestood the conditions. You can use multiple if dax for nesting.
For example:
measure = VAR _a = "Good" VAR _b = "Fair" VAR _c = "Pass" VAR _d = "Not pass" RETURN IF ( 'table'[value] >= 100, _a, IF ( 'table'[value] >= 80, _b, IF ( 'table'[value] >= 60, _c, _d ) ) )Or try to use SELECTEDMEASURE: Used by expressions for calculation items to reference the measure that is in context.
like the following:
measure=switch( value(selectedmeasure()), >0.9, "red","green")If I have misunderstood your meaning, please provide you pbix file without privacy information and your desired output.
How to Get Your Question Answered Quickly
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.