Forum Discussion

mhablas426's avatar
mhablas426
Advocate II
1 year ago
Solved

Conditional formatting Dax

Dears,
I hope you all are doing well,
i want to write DAX to make conditional formatting for the "fuel last date" column in this visual table.
to display in red color if they exceed the number in the "Max per day" column and green if they do not exceed.
please note that: Fuel last Date is a measure and Max per day is a calculated column.

Fuel last Date = CALCULATE(
                         [Fuel Total Quantity],
                         FILTER('F Dim Date','F Dim Date'[Date] = MAX('F Dim Date'[Date]))
I think It's maybe I have to use SUMMARIZE&LOOKUPVALUE and make it a regular table.
Expected result all numbers above 400 are displayed in red and those under 400 in green.

 

Thanks

  • FreemanZ's avatar
    FreemanZ
    1 year ago

    hi mhablas426 , 

     

    it is supposed be applied to the measure field of the visual, like this:

     

7 Replies

  • some_bih's avatar
    some_bih
    Community Champion

    Hi mhablas426 try measure definition below (save your work before)

    Fuel last Date =
    VAR __max_date=MAX('F Dim Date'[Date])
    RETURN
    CALCULATE(
    [Fuel Total Quantity],
    FILTER('F Dim Date','F Dim Date'[Date] = __max_date))

    • mhablas426's avatar
      mhablas426
      Advocate II

      Hi some_bih 
      I've been using your DAX formula instead of mine. Would you mind explaining the differences between the two.

      but my main concern is about applying conditional formatting for this visual table could you please advise

      • some_bih's avatar
        some_bih
        Community Champion

        Hi mhablas426 at moment when I saw your measure I understand that you want to filter max date so I rewrite your measure.

    • mhablas426's avatar
      mhablas426
      Advocate II

      Dear FreemanZ 
      Thanks for reply

      Fuel last Date color =
      IF (
          CALCULATE (
              [Fuel Total Quantity],
              FILTER ( 'F Dim Date', 'F Dim Date'[Date] = MAX ( 'F Dim Date'[Date] ) )
          )
              > MAX ( 'BI Fuel Issue'[Max per Day] ),
          "red",
          "green"
      )


      I tried to use it, but I can't select it. How can I resolve this, or what could be the issue?
      Kindly see the snapshot

       


      Thanks,

      • FreemanZ's avatar
        FreemanZ
        Super User

        hi mhablas426 , 

         

        it is supposed be applied to the measure field of the visual, like this: