Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello -
I am working on subtracting Current Data with Past Data using a unique ID to find the last historic value for each unique item. I have successfully calculated the previous value by using the following DAX function:
Previous Data =
'Table'[Current Data]
- MAXX(
FILTER('Table',
'Table'[Index]
= EARLIER('Table'[Index]) - 1
&& 'Table'[UID] = EARLIEST('Table'[UID])
),
'Table'[Current Data]
)
Now that I have this value, I want to subract the each individual row from 'Table' [Current Data] from 'Table' [Previous Data] to get a delta/change value for each row. I used the following as an example:
Delta = 'Table'[Current Data] - 'Table'[Previous Data]
However, when using the above "Delta" calculation all of the values result as "0", and I cannot understand why this is happening.
Below is an example of what I would expect to happen with the delta calculation:
UID | Date | Current Data | Previous Data | Delta |
1 | 2/3/21 | 5747 | 8532 | (2785) |
2 | 2/3/21 | 4672 | 2134 | 2538 |
1 | 1/5/21 | 8532 | 8532 | 0 |
3 | 1/3/21 | 9419 | 7128 | 2291 |
2 | 1/6/21 | 2134 | 9024 | (6890) |
2 | 1/2/21 | 9024 | 9024 | 0 |
3 | 12/4/20 | 7128 | 7128 | 0 |
Thank you in advance for any assistance!
Solved! Go to Solution.
@Anonymous ,a new column, you can use index in place of date
Diff Previous Data =
var _max = maxx(filter( 'Table','Table'[UID] = EARLIEST('Table'[UID]) , 'Table'[Date] < EARLIER('Table'[Date])),[Date])
return
if(isblank(_max) , 0 , [Current Data] -maxx(filter( 'Table','Table'[UID] = EARLIEST('Table'[UID]) , 'Table'[Date] =_max),[Current Data] ) )
This seems to have worked perfectly! Thank you!
@Anonymous ,a new column, you can use index in place of date
Diff Previous Data =
var _max = maxx(filter( 'Table','Table'[UID] = EARLIEST('Table'[UID]) , 'Table'[Date] < EARLIER('Table'[Date])),[Date])
return
if(isblank(_max) , 0 , [Current Data] -maxx(filter( 'Table','Table'[UID] = EARLIEST('Table'[UID]) , 'Table'[Date] =_max),[Current Data] ) )
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
126 | |
113 | |
71 | |
65 | |
46 |