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
teo_87
New Member

Compare data with variable period

Hi all,

 

I have a CRM dataset composed by opportunities & related details. The opportunities are replicated per each snapshot (for sake of seplicity, let's say one snapshot per week). All in one table called DB

 

I want to compare the opportunities that I have today with snapshots in the past. 

The particularity is that i want to be able to select to which of the several available past snapshot to compare it with.

 

So far I have created a calculated table with only today's information, a Measure that grabs the Snapshot date selected (  

Comparison_Date = SELECTEDVALUE(Available_Snapshots[Available Snapshots])
)
but i cannot get my head around how to compare data with the selected snapshot. I cannot bring the Measure into A calculated columns to do a lookup, neither I can compare two values in a measure (as far as I know)
 
Any suggestions on how to proceed from here?
Thanks
Matteo
1 REPLY 1
Anonymous
Not applicable

Mate, I can see you've got a data modeling problem, not a DAX problem 🙂

 

Here's how I see it. Let's say each week you get a new snapshot of the same shape, only measurements change. Snapshots are S_i, i=1,...,n. Each snapshot has columns C_j, j=1,...,m. One of the columns, but fixed, in each of the snapshots must identify the snapshot, say its name's SnapshotID (or SnapshotName, whatever that makes the snapshot rows unique among all the rows from all the snapshots). Then you stack up the snapshots on top each other. This is the Master Snapshot (your fact table). Then out of this you create your dimensions using PQ (if you have not yet done it), or the so-called lookup tables, and you join them to the right columns in the Master Snapshot (which should be hidden as much as the other snapshots, if you've imported them into your model). 

 

This way you've created the celebrated STAR SCHEMA 🙂 Once you've got this, the rest is rather easy. One of the dimensions (lookup tables) should hold the identifiers of the individual snapshots (SnapshotName or SnapshotID), so that you can create a slicer and select the snapshot you want to compare to. If the latest snapshot is the one you always want to compare the others to, then you could call it something like "Most Recent" as the SnapshotName (or SnapshotID). You could also store the latest snapshot separately from the old ones (which you've combined into the Master Snapshot). Both, the latest and the MS would be hidden anyway because in a good model only the dimensions are exposed together with measures. Bear in mind that dimensions should join to facts in a 1:many fashion.

 

Once you've done the data modeling part, you can write your measures. Let's say that you have the Master Snapshot with historical data and the Most Recent snapshot separated. You would then create a slicer that would hold the identifiers of the old snapshots (the ones to compare with the most recent one). For each metric you'd want to make a comparison with you'd define 2 measures - one measure would calculate the thing on the MS and the other on the Most Recent.

 

Put the slicer with the names of the historical snapshots on the canvass. Let the user select only one identifier at a time. Then create a table/matrix to show values from the MS (which will be filtered by the slicer) and the same metric defined for the Most Recent snapshot (which will act independently of the selection in the slicer).

 

You could also, alternatively, put all the snapshots into one Master Snapshot, together with the latest one, and basically do the same as above. The only change you'd need is adjusting the measures so that there is one that always shows data from the Most Recent snapshot and the other one from the one you've selected in the slicer. But that's a cinch.

 

Best

Darek

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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