Forum Discussion

Saxon10's avatar
Saxon10
Post Prodigy
5 years ago
Solved

Conditional Formatting in visualization based on the multiple columns and criteria

  Hi,   I have a two tables one is Data and another one os Report. Both tables contain the following columns are Fruits List, Area Code, Language, Sales Code.     I am trying to make a Condition...
  • MFelix's avatar
    MFelix
    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).