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.
I have a table that looks a lot like this:
[TimeStamp] | [ProjectID] | [Score] |
01/15/2022 | PRJ01 | 10 |
01/15/2022 | PRJ02 | 1000 |
01/15/2022 | PRJ03 | 1 |
01/14/2022 | PRJ01 | 14 |
01/14/2022 | PRJ02 | 999 |
01/14/2022 | PRJ03 | 2 |
01/13/2022 | PRJ01 | 8 |
01/13/2022 | PRJ02 | 989 |
01/13/2022 | PRJ03 | 1 |
I want to calculate the change in [Score] of [ProjectID] from previous [TimeStamp] and put it into a custom column like this:
[Change Since Previous Entry] |
4 |
1 |
-1 |
6 |
10 |
1 |
<blank> |
<blank> |
<blank> |
But I am at a complete loss on where to start.
Solved! Go to Solution.
Hi,
Assuming your table is named 'MyTable', this Calculated Column:
Column =
VAR TimeStamp = MyTable[TimeStamp]
VAR ProjectID = MyTable[ProjectID]
VAR PreviousTimeStamp =
CALCULATE(
MAX( MyTable[TimeStamp] ),
FILTER(
MyTable,
MyTable[ProjectID] = ProjectID
&& MyTable[TimeStamp] < TimeStamp
)
)
RETURN
IF(
ISBLANK( PreviousTimeStamp ),
BLANK(),
MyTable[Score]
- CALCULATE(
MIN( MyTable[Score] ),
FILTER(
MyTable,
MyTable[ProjectID] = ProjectID
&& MyTable[TimeStamp] = PreviousTimeStamp
)
)
)
Regards
Hi,
Assuming your table is named 'MyTable', this Calculated Column:
Column =
VAR TimeStamp = MyTable[TimeStamp]
VAR ProjectID = MyTable[ProjectID]
VAR PreviousTimeStamp =
CALCULATE(
MAX( MyTable[TimeStamp] ),
FILTER(
MyTable,
MyTable[ProjectID] = ProjectID
&& MyTable[TimeStamp] < TimeStamp
)
)
RETURN
IF(
ISBLANK( PreviousTimeStamp ),
BLANK(),
MyTable[Score]
- CALCULATE(
MIN( MyTable[Score] ),
FILTER(
MyTable,
MyTable[ProjectID] = ProjectID
&& MyTable[TimeStamp] = PreviousTimeStamp
)
)
)
Regards
Thank you. I was lost with the calculation of the PreviousTimestamp. Was trying to find a way to do it by index of a DISCRETE([TimeStamp]) and that obviously doesn't work.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
101 | |
79 | |
72 | |
64 |
User | Count |
---|---|
142 | |
108 | |
101 | |
81 | |
74 |