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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Matrix condition based on week

Hello

I am still new to this conditional formatting in matrix

try to search on other case, still not working

 

I need help on Conditional formatting in matrix based on week 

I want this matrix visual but in week format

 

ChristoNindyo_0-1701073480746.png

 

ChristoNindyo_1-1701073529675.png

 

Thank you

 

2 ACCEPTED SOLUTIONS
speedramps
Super User
Super User

Click here to download the solution

Download PBIX 

 

How it works ..

 

Create a calendar table from start to end date

Calendar =
CALENDAR(DATE(2020,01,01),DATE(2023,12,31))
 
Create a calulated column
Week =
YEAR('Calendar'[Date])
& "-" &
FORMAT(WEEKNUM('Calendar'[Date],2),"00")
 
 
Buld a relationship to tehn calendar table
speedramps_0-1701083804002.png

 

 

 

Build your report

 

speedramps_1-1701083968081.png

 

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,
This solution works and does exactly what you asked.
So please quickly click the [accept as solution] and the thumbs up button to leave kudos. 

One question per ticket please. If you need to change or extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please now click the [accept as solution] and the thumbs up button.  Thank you.

 

View solution in original post

speedramps
Super User
Super User

Click here to download the solution, then please click accept solution.
Click to download PBIX 

 

How it works ...

 

Create a measure 

RAG = 
VAR mymindate = MIN('Calendar'[Date])
VAR previousweek = 
CALCULATE(
    MAX('Calendar'[Week]),
    'Calendar'[Date] < mymindate)
VAR previousvalue =
CALCULATE(
    SUM(Sales[Amount]),
    'Calendar'[Week] = previousweek)
VAR thisvalue =
SUM(Sales[Amount])

RETURN
SWITCH( 
    TRUE(),
thisvalue < previousvalue,"red",
thisvalue > previousvalue,"green"
)

 

Then add field based colour formating 

speedramps_0-1701086606973.png

 

 

View solution in original post

5 REPLIES 5
speedramps
Super User
Super User

Click here to download the solution, then please click accept solution.
Click to download PBIX 

 

How it works ...

 

Create a measure 

RAG = 
VAR mymindate = MIN('Calendar'[Date])
VAR previousweek = 
CALCULATE(
    MAX('Calendar'[Week]),
    'Calendar'[Date] < mymindate)
VAR previousvalue =
CALCULATE(
    SUM(Sales[Amount]),
    'Calendar'[Week] = previousweek)
VAR thisvalue =
SUM(Sales[Amount])

RETURN
SWITCH( 
    TRUE(),
thisvalue < previousvalue,"red",
thisvalue > previousvalue,"green"
)

 

Then add field based colour formating 

speedramps_0-1701086606973.png

 

 

speedramps
Super User
Super User

Thanks for thumbs up. Please also click accept as solution. It does exacty what you asked for.

If you need something else then please raise a new ticket.

speedramps
Super User
Super User

Click here to download the solution

Download PBIX 

 

How it works ..

 

Create a calendar table from start to end date

Calendar =
CALENDAR(DATE(2020,01,01),DATE(2023,12,31))
 
Create a calulated column
Week =
YEAR('Calendar'[Date])
& "-" &
FORMAT(WEEKNUM('Calendar'[Date],2),"00")
 
 
Buld a relationship to tehn calendar table
speedramps_0-1701083804002.png

 

 

 

Build your report

 

speedramps_1-1701083968081.png

 

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers, and you have got free expert help which took a lot of effort,
This solution works and does exactly what you asked.
So please quickly click the [accept as solution] and the thumbs up button to leave kudos. 

One question per ticket please. If you need to change or extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

If you quote @speedramps in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please now click the [accept as solution] and the thumbs up button.  Thank you.

 

Anonymous
Not applicable

Hello @speedramps , thank you for your answer. I'm sorry if my question is not clear.

But what I mean is how to make the conditional formatting based on the week in the data.

ChristoNindyo_1-1701085102228.png

 

For example :

if the second week = third week -> the background would be yellow

if the 4th week > third week -> the background would be blue

 

I manage to do that but with month 

I made measure with date table :

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

Then have measures like

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

 

Create a new measure

color = Switch(true(),

[Diff] <0, "pink",

[Diff] <0, "Yellow",

"blue"

)

Is there any work around to do similar with that but with week data ?

 

Please keep descriptions and clear and concise and just ask one question per ticket.

Dont post your dax that does not work and expect us to fathom what you need.

I have answered your weekly question.

 

Having lots  > and - in your seconf question is very confussing.

Why not simply say you want red if any week is less than previous week and green if its greater.

Keep questions simple.

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.