Forum Discussion

moumipanja's avatar
moumipanja
Microsoft Employee
7 years ago
Solved

Conditional formatting based on Field value

I have 2 tables showing project details and the stage each project.   Table Project:   Table Stage:   I have created a matrix visualization that display the total revenue for each p...
  • TomMartens's avatar
    TomMartens
    7 years ago

    Hey,

     

    based on your sample file I created this measure and assigned the measure to the table: Project

    viz Aid - FontColor Revenue = 
    var theProject = SELECTEDVALUE('Project'[Project],BLANK())
    var theLastDate = CALCULATE(MAX('Project'[Date]),'Project'[Project] = theProject) 
    var theStage = CALCULATE(FIRSTNONBLANK('Project'[Stage],0),'Project'[Date] = theLastDate, 'Project'[Project]=theProject)
    var theColor = LOOKUPVALUE(Stage[Color],Stage[Stage], theStage)
    return
    theColor

    It may look somewhat complicated, but with this measure it is possible to retrieve the stage value from the last date of a project. This value is used to pull the color from the stage table using the LOOKUPVALUE(...) function.

     

    The measure "just" returns the color that is associated with the stage value.

     

    Then I used "Conditional Formatting" on the font color on the revenue in the matrix visual like so:

     

    The result looks like this

     

    And here is a link to your sample file that contains my solution:

    https://tommartens-my.sharepoint.com/:u:/g/personal/tom_minceddata_com/Ec8kisooDXlMhAHxAXywSLgByBuUkxQvYRFm0RNflcze1A?e=SP2YwZ

     

    Regards,

    Tom