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.
Hi
I have a single table that looks like this.
Category | DateTime | Value
A | 29/11/2021 22:21:24 | $48
A | 30/11/2021 10:15:56 | $52
A | 30/11/2021 16:24:32 | $90
B | 28/11/2021 09:08:43 | $16
B | 29/11/2021 11:25:54 | $18
B | 29/11/2021 12:26:21 | $29
B | 29/11/2021 13:42:28 | $82
I am trying to find a DAX formula that will calculate both first and latest values for both A and B, so that it delivers something that looks like this:
Category | FirstValue | LatestValue
A | $48 | $90
B | $16 | $82
I have tried many options but none gives me what I need.
Solved! Go to Solution.
@Etienne123
Create two measure as follows:
FirstValue = FIRSTNONBLANK(Table1[ Value] , MAX(Table1[ DateTime ] ))
LastValue = LASTNONBLANK(Table1[ Value] , MAX(Table1[ DateTime ] ))
Add them in a matrix
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi @Etienne123 ,
You could use the following formula to create a new table:
NewTable =
ADDCOLUMNS (
VALUES ( 'Table'[Category] ),
"FirstValue",
VAR _firstdate =
MINX ( FILTER ( 'Table', [Category] = EARLIER ( [Category] ) ), [DateTime] )
RETURN
LOOKUPVALUE ( 'Table'[Value], [Category], [Category], [DateTime], _firstdate ),
"LatestValue",
VAR _lastdate =
MAXX ( FILTER ( 'Table', [Category] = EARLIER ( [Category] ) ), [DateTime] )
RETURN
LOOKUPVALUE ( 'Table'[Value], [Category], [Category], [DateTime], _lastdate )
)
Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Etienne123
Create two measure as follows:
FirstValue = FIRSTNONBLANK(Table1[ Value] , MAX(Table1[ DateTime ] ))
LastValue = LASTNONBLANK(Table1[ Value] , MAX(Table1[ DateTime ] ))
Add them in a matrix
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
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 |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
152 | |
120 | |
102 | |
87 | |
68 |