Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
mhablas426
Advocate II
Advocate II

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.

Screenshot 2024-11-03 132015.jpg

 

Thanks

1 ACCEPTED SOLUTION

hi @mhablas426 , 

 

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

FreemanZ_0-1730703526765.png

 

View solution in original post

7 REPLIES 7
FreemanZ
Super User
Super User

hi @some_bih ,

 

try to apply conditional formating with a measure like:

Fuel last Date color= 

IF(

CALCULATE(

      [Fuel Total Quantity],

      FILTER(

         'F Dim Date',

         'F Dim Date'[Date] = MAX('F Dim Date'[Date])

    )

) > MAX(data[Max per day]),

    "red", "green"

)

 

more about conditional formatting:

https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-conditional-table-formatting

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
Untitled.png

 


Thanks,

hi @mhablas426 , 

 

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

FreemanZ_0-1730703526765.png

 

Dear @FreemanZ 
It Works.
The problem was that the column "max capacity per day " from the original table was formatted as text, not a number, preventing the code from working.
I would like to thank you too much for your time and effort, have a nice day
Screenshot 2024-11-04 092128.jpg

some_bih
Super User
Super User

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))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






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

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.