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.
Hi, i have a "status rag" field that is either reg, amber or green.
I wish to have a card (or possibly table field?) that changes colour dependent on the value. I have tried 'cards with states' by OKviz, but this appears to only work with numeric values, as does conditional formatting in tables.
So have tried to create a measure that returns a numeric value,-
zzStatusToNumeric = Switch ( True(), 'Projects (2)'[StatusRAG] = "Red","1" )
but have received an error:-
This is the field i am trying to reference:-
Note thet there is a slicer on for 'project' so there is only one relevant row on the table. I think i need to limit the measure to FIRST (or similar) but am struggling...
Solved! Go to Solution.
hi, @Anonymous
First, you should know the difference between measure and column.
Notice:
1. Calculation column/table not support dynamic changed based on filter or slicer.
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result.
A measure operates on aggregations of data defined by the current context
here is reference:
https://community.powerbi.com/t5/Desktop/Different-between-calculated-column-and-measure-Using-SUM/t...
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
Second, for you requirement, you could try this way
Use SELECTEDVALUE in your formula, so adjust your measure like this:
zzStatusToNumeric = Switch ( True(), SELECTEDVALUE( 'Projects (2)'[StatusRAG] )= "Red","1" )
or add a "zzStatusToNumeric column" then Conditional Formatting based it by the same logic.
Best Regards,
Lin
hi, @Anonymous
First, you should know the difference between measure and column.
Notice:
1. Calculation column/table not support dynamic changed based on filter or slicer.
2. Measure can be affected by filter/slicer, so you can use it to get dynamic summary result.
A measure operates on aggregations of data defined by the current context
here is reference:
https://community.powerbi.com/t5/Desktop/Different-between-calculated-column-and-measure-Using-SUM/t...
https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/
Second, for you requirement, you could try this way
Use SELECTEDVALUE in your formula, so adjust your measure like this:
zzStatusToNumeric = Switch ( True(), SELECTEDVALUE( 'Projects (2)'[StatusRAG] )= "Red","1" )
or add a "zzStatusToNumeric column" then Conditional Formatting based it by the same logic.
Best Regards,
Lin
Thanks Lin. Apologies for the deay in replying but we decided to park this requriement, but we are now back trying to get this working.
A couple of questions.
zzStatusRAGtoNumeric = Switch ( True(), SELECTEDVALUE( 'Projects (2)'[StatusRAG] )= "Red","1" ,"Amber", "2", "Green" , "3")
I have then added a column to give a solid circle to conditionally format
zzStatusRAG_UNICHAR_Column = UNICHAR(11044)
Feedback Type: Frown (Error) Timestamp: 2019-07-30T09:28:35.0326414Z Local Time: 2019-07-30T10:28:35.0326414+01:00 Session ID: 56322f8b-fde1-4de1-b539-95c572e00cf8 Release: June 2019 Product Version: 2.70.5494.761 (19.06) (x64) Error Message: MdxScript(Model) (27, 70) Calculation error in measure 'Projects (2)'[zzStatusRAGtoNumeric]: Function 'SWITCH' does not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.Any ideas what i am doing wrong? @v-lili6-msft
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 |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
146 | |
108 | |
106 | |
90 | |
62 |