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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kinseld5
Helper II
Helper II

Comparing data to previous date (not necessarily yesterday)

Hi,

 

I have two problems that i need help with please.

 

Problem 1 - I'd like to get the 'Swap Completed' column to say 1, when there is a change from Yes to No in the' Change' column. The equation i am using is not working and i cannot figure out why. 

 

Problem 2 - Sometimes the data feed into our database fails and we lose some dated information, in the example below you can see that the 29th and 30th July are missing. Can the equation be manipulated to look for the most recent previous day, as opposed to just yesterday?

 

Thanks, David

 

kinseld5_1-1691578295118.png

kinseld5_2-1691578471931.png

Swap Completed =
VAR __var1 = 'SRAN Tracker'[radioHB - Sec A Swap]
VAR __var2 = CALCULATE(VALUES('SRAN Tracker'[radioHB - Sec A Swap]), FILTER(ALL('SRAN Tracker'), 'SRAN Tracker'[Date created] = EARLIER('SRAN Tracker'[Date created]) -1 && 'SRAN Tracker'[Nominal] = EARLIER('SRAN Tracker'[Nominal])))
RETURN
IF(ISBLANK(__var2), 0, IF(__var1 = __var2, 0, 1))

 

 

 

2 REPLIES 2
Dhairya
Solution Supplier
Solution Supplier

Hey @kinseld5 
Can you please let me know whether "change" is your column or a measure?
If it is a column then you can use the below measure to calculate "Swap Completed"

Swap Completed = 
IF ( SELECTEDVALUE( 'SRAN Tracker'[Change] ) = "Yes", 0, 1 )

 

 

Your equation will not do what i require unfortunately, i need a change in column 'Change' i.e. from Yes to No to result in a 1 in the 'Swap Completed' column. The equation sent in my original post is a column. Also the the Nominal shown is not the only Nominal in the dataset, i'm just using this as an example.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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