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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.