Forum Discussion
Conditional Formatting in visualization based on the multiple columns and criteria
- 5 years ago
Hi Saxon10 ,
Looking at the data you have and taking into account that you need several formattings to different columns I did the following:
- Added an ID column to each of the tables:
ID = Report[FRUIT LIST] & Report[AREA CODE]&Report[SALES CODE] ID = Data[FRUIT LIST]&Data[AREA CODE]&Data[SALES CODE]- Hide the column in the report view
- Created the following 4 measures:
FORMATTING FRUITLIST = IF ( LOOKUPVALUE ( Data[FRUIT LIST]; Data[FRUIT LIST]; SELECTEDVALUE ( Report[FRUIT LIST] ) ) = BLANK(); "Orange"; "Green" ) FORMATTING AREACODE = IF ( LOOKUPVALUE ( Data[ID]; Data[ID]; MAX ( Report[ID] ) ) = BLANK (); IF ( LOOKUPVALUE ( Data[AREA CODE]; Data[AREA CODE]; SELECTEDVALUE ( Report[AREA CODE] ); Data[FRUIT LIST]; SELECTEDVALUE ( Report[FRUIT LIST] ) ) = BLANK(); "Orange" ) ) FORMATTING LANGUAGE = IF(SELECTEDVALUE(Report[LANGUAGE]) = BLANK(); "Orange") FORMATTING SALESCODE = IF ( LOOKUPVALUE ( Data[ID]; Data[ID]; MAX ( Report[ID] ) ) = BLANK (); IF ( LOOKUPVALUE ( Data[SALES CODE]; Data[SALES CODE]; SELECTEDVALUE ( Report[SALES CODE] ); Data[FRUIT LIST]; SELECTEDVALUE ( Report[FRUIT LIST] ) ) = BLANK(); "Orange" ) )Now I use this measure to condittional format each of the columns in the visualization:
You can change the colours by a format string similar to "#000000" and use the HEX codes.
PBIX file attach (PBI December version).
Hi
Thanks you so much for your prompt action about my thread.
I like way of your approach. Can you please help me regarding my question.
- Did you added area code with fruits list combination for "FORMATTING AREACODE" measure? I can see the fruits list on your measure but just clarifying the thoughts.
2.How can I added "area code" in exciting measure because the sales code matching logic/criteria is FRUIST LIST + AREA CODE + SALES CODE. If we try to match the area code and sales code maybe the results went wrong.
3. Can you please explain if it possibile about your logic and selected value logic?