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
springje
Frequent Visitor

DAX for comparing text fields of snapshot data

I have the following data set:

image.png

I am creating a matrix with Snapshot as the column, Attribute as the row, and I need a measure for using Value as the values. I am comparing the text of the Value column between the 2 snapshots, so I have a slicer for Snapshot that the user will select 2 snapshots.

image.png
I need the Total column to show "Changed" if the values are different, and "Same" or blank if the values are the same. I'm struggling with writing a measure to do this.

1 ACCEPTED SOLUTION

I was able to solve this one:

IF(HASONEVALUE(Data[Snapshot]),FIRSTNONBLANK(Data[Value],0),IF(EXACT(LASTNONBLANK(Data[Value],0),FIRSTNONBLANK(Data[Value],0)),"SAME","CHANGED"))

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

Well, you are going to need an index or other "order" column so that you know what is before/after what, that should be a combination of your snapshot column and your attribute column. Then you are going to need to use EARLIER. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I'm not trying to compare everything in the table together, just the column values that are sliced to in the matrix. My data will be a monthly snapshot of the same dataset stored in the same table, and I want to look at an attribute and see whether it is the same, or different, in 2 selected snapshots.

 

I've been able to do this looking at dates as values and getting the difference between the dates, but I'm unsure how to do this with text values.

 

It is a fairly simple measure to do this with dates: https://community.powerbi.com/t5/Desktop/Compare-milestone-dates-of-snapshot-data-in-same-table/m-p/...

I was able to solve this one:

IF(HASONEVALUE(Data[Snapshot]),FIRSTNONBLANK(Data[Value],0),IF(EXACT(LASTNONBLANK(Data[Value],0),FIRSTNONBLANK(Data[Value],0)),"SAME","CHANGED"))

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.

Top Solution Authors