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 normally use the below DAX to retrieve a value from a pevious row, which works fine if the MAX value is a number. But what do I do if I am trying to get a value from a column that is a text or boolean type?
=
CALCULATE
(
MAX
(
'Sample Data'[Sample Taken]
),
FILTER
(
'Sample Data',
'Sample Data'[Sample Date] < EARLIER
(
'Sample Data'[Sample Date]
)
&& 'Sample Data'[Unit Number] = EARLIER
(
'Sample Data'[Unit Number]
)
)
)
Hi @justlogmein ,
Has this question been solved? If you have solved it, you can post your solution here. If any of the responses were helpful to you, please consider marking them as solutions, which will help more users find similar problems faster. If the question is not solved, please feel free to let us know. Thanks in advance!
Best Regards,
Gao
Community Support Team
Hi @justlogmein
please use
=
VAR CurrentDate = 'Sample Data'[Sample Date]
VAR CurrentUnitTable =
CALCULATETABLE (
'Sample Data',
ALLEXCEPT ( 'Sample Data', 'Sample Data'[Unit Number] )
)
VAR DatesBeforeTable =
FILTER ( CurrentUnitTable, 'Sample Data'[Sample Date] < CurrentDate )
VAR PreviousDate =
MAXX ( DatesBeforeTable, 'Sample Data'[Sample Date] )
RETURN
MAXX (
FILTER ( DatesBeforeTable, 'Sample Data'[Sample Date] = PreviousDate ),
'Sample Data'[Sample Taken]
)
Unfortunately I get an error.
Please try
=
VAR CurrentDate = 'Sample Data'[Sample Date]
VAR CurrentUnitTable =
CALCULATETABLE (
'Sample Data',
ALLEXCEPT ( 'Sample Data', 'Sample Data'[Unit Number] )
)
VAR DatesBeforeTable =
FILTER ( CurrentUnitTable, 'Sample Data'[Sample Date] < CurrentDate )
VAR PreviousDate =
MAXX ( DatesBeforeTable, 'Sample Data'[Sample Date] )
RETURN
SELECTCOLUMNS (
FILTER ( DatesBeforeTable, 'Sample Data'[Sample Date] = PreviousDate ),
"@Taken", 'Sample Data'[Sample Taken]
)
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 |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
19 |