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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ChiRomeu
Helper I
Helper I

Dax measure for conditional formatting for matrix table on cells

Dear members,

 Please kindly help to solve the following problema:

I would like to have conditional formatting request in the matrix table: see the following picture

Green = 2

Red =1

Write=0

With color green:

If current month bookings > 0 and  last three months bookings = 0 then 2 (which means the cell of date (year-month) 2024-05 is green)

ChiRomeu_0-1716376837457.png

 

With color red:

Two requests:

No Regular red:

If current month and last month = 0 and -2 month and -3 month >0 then 1 (which means the cells of date (year-month) 2024-05 y 2024-04 are red)

ChiRomeu_1-1716376837459.png

 

Regular red:

If current month =0 and last month > 0 and -2 month and -3 month >0 then 1 (which means the cell of date (year-month) 2024-05 is red)

Otherwise:

write

 

Best regards

Chi

2 REPLIES 2
v-kongfanf-msft
Community Support
Community Support

Hi @ChiRomeu ,

 

You can try formula like below:

BookingStatus = 
VAR CurrentDate = SELECTEDVALUE(slicer[Date])
VAR CurrentBookings = CALCULATE(SUM(Bookings[Bookings]), Bookings[Date] = CurrentDate)
VAR LastMonth = CALCULATE(SUM(Bookings[Bookings]), DATEADD(Bookings[Date], -1, MONTH))
VAR TwoMonthsAgo = CALCULATE(SUM(Bookings[Bookings]), DATEADD(Bookings[Date], -2, MONTH))
VAR ThreeMonthsAgo = CALCULATE(SUM(Bookings[Bookings]), DATEADD(Bookings[Date], -3, MONTH))

RETURN
SWITCH(
    TRUE(),
    CurrentBookings > 0 && LastMonth = 0 && TwoMonthsAgo = 0 && ThreeMonthsAgo = 0, 2,
    CurrentBookings = 0 && LastMonth = 0 && TwoMonthsAgo > 0 && ThreeMonthsAgo > 0, 1,
    CurrentBookings = 0 && LastMonth > 0 && TwoMonthsAgo > 0 && ThreeMonthsAgo > 0, 1,
    0
)

Then create rule in conditional formatting:

vkongfanfmsft_0-1716446358443.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Adamk  Kongs,

 Thank you for your help, but it is still not working, please see the following picture marked which violates the conditions put.

ChiRomeu_0-1716461144037.png

 beste regards

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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