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
Anonymous
Not applicable

compare day vs day with conditional formatting

Hii,.

 

As the pic below (ex : in excel) I need to compare the today vs yesterday (ex : 29 Nov vs 28 Nov / 31 Nov vs 30 Nov / 1 Dec vs 30 Nov etc.)

 

expected result : the arrow in the matrix show data up/equal/down, today compared to yesterday.

please explain in detail, iam beginner on dax.  thanks before

 

 

Ex : Expected Matrix 

rifkif_0-1639578428498.jpeg

 

ex :  RAW data

Transcation DateRegionActual
11/28/2021A1
11/29/2021B10
11/30/2021B11
12/1/2021B11
12/2/2021A3
12/3/2021A2
12/4/2021A54
12/5/2021C1
12/6/2021C25
12/7/2021C15
12/8/2021D5
12/9/2021E6
12/10/2021F5
12/11/2021F15
12/12/2021G1
12/13/2021H1
12/14/2021L1
12/15/2021M8
12/16/2021N1
1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this code to find the variance for each Date vs Yesterday:

Arrow = 
Var _SelectedDate = max('Table'[Transcation Date]) --this will return the column date
Var  _Yesterday = _SelectedDate-1 -- this will return the yesterday date
Var _SelectedDateValue = sum('Table'[Actual]) -- this will return the column date actual value
Var __YesterdayValue = CALCULATE(sum('Table'[Actual]),removefilters('Table'[Transcation Date]),'Table'[Transcation Date]=_Yesterday)
return
if(ISBLANK(__YesterdayValue),0,__YesterdayValue-_SelectedDateValue) -- if th value of Yesterday is blank it will show Zero because nothing changed 

 

The output will be like this:

VahidDM_0-1639631916907.png

 

Now you need to set a conditional formatting based on this measure [Arrow]:

select Icon on the conditional formatting of Arrow in the Value section of the Matrix visual:

VahidDM_1-1639632014016.png

set this:

VahidDM_3-1639632331918.png

 

 

Output:

VahidDM_4-1639632411572.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

woooow you're awesome both!! very helpful

thank you very much!!

VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this code to find the variance for each Date vs Yesterday:

Arrow = 
Var _SelectedDate = max('Table'[Transcation Date]) --this will return the column date
Var  _Yesterday = _SelectedDate-1 -- this will return the yesterday date
Var _SelectedDateValue = sum('Table'[Actual]) -- this will return the column date actual value
Var __YesterdayValue = CALCULATE(sum('Table'[Actual]),removefilters('Table'[Transcation Date]),'Table'[Transcation Date]=_Yesterday)
return
if(ISBLANK(__YesterdayValue),0,__YesterdayValue-_SelectedDateValue) -- if th value of Yesterday is blank it will show Zero because nothing changed 

 

The output will be like this:

VahidDM_0-1639631916907.png

 

Now you need to set a conditional formatting based on this measure [Arrow]:

select Icon on the conditional formatting of Arrow in the Value section of the Matrix visual:

VahidDM_1-1639632014016.png

set this:

VahidDM_3-1639632331918.png

 

 

Output:

VahidDM_4-1639632411572.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

amitchandak
Super User
Super User

@Anonymous , With help from date table, you can get day on day diff %

 

This Day = sum('Table'[Qty])

or

This Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))

 

Last Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))

or

Last Day = CALCULATE(sum('Table'[Qty]), previousday('Date'[Date]))

 

diff %=divide([This Day] - [Last Day], [Last Day])

 

In conditional formatting you have option for icon formatting that you can use

https://exceleratorbi.com.au/conditional-formatting-using-icons-in-power-bi/
https://community.powerbi.com/t5/Desktop/FORMAT-icon-set-for-use-in-a-data-card/td-p/811692

 

Also using unichar you can create a arrow measure and color that using color measure in conditional formatting field value option

 

/////Arrow
Arrow =
var _change =[Net Sales YTD]-[Net Sales LYTD]
return
SWITCH (
TRUE(),
_change > 0, UNICHAR(9650),
_change = 0, UNICHAR(9654),
_change < 0, UNICHAR(9660)
)


/////Arrow Color
Arrow color =
var _change =[Net Sales YTD]-[Net Sales LYTD]
return
SWITCH (
TRUE(),
_change > 0, "green",
_change = 0, "blue",
_change < 0, "red"
)

 

UNICHAR - Tool for Custom Icon Formatting: https://www.youtube.com/watch?v=veCtfP8IhbI&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=50

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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