Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
136 | |
118 | |
101 | |
71 | |
61 |