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 am trying to calculate minimum start_date as IPST for a customer as below-
IPST = VAR Per=SELECTEDVALUE(Patient_Population2[Person_id])
RETURN MINX(FILTER(Patient_Population2,Patient_Population2[Person_id]=Per),Patient_Population2[start_date].[Date])
I am using a table visual.
Patient_Population2 table lists all the start_dates for a customer.
But what I am getting is a value similar to start_date column for IPST, see screen shot below
I am expecting the output to be this
The problem here is that in the call to Filter() the reference to Patient_Population2 brings in the value of the start_date as part of the filter context. So when you calcuate the first row it's filtering for the min of start_date where start_date = 11/5/2018.
One way to fix this would be to wrap the table reference in the ALL() function
IPST = VAR Per=SELECTEDVALUE(Patient_Population2[Person_id]) RETURN MINX(FILTER( ALL( Patient_Population2 ),Patient_Population2[Person_id]=Per),Patient_Population2[start_date].[Date])
A different pattern which should achieve the same effect and is slightly simpler is the following
IPST = VAR Per=SELECTEDVALUE(Patient_Population2[Person_id]) RETURN CALCULATE( MIN(Patient_Population2[start_date].[Date]), Patient_Population2[Person_id] = Per)
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 |
---|---|
14 | |
6 | |
4 | |
3 | |
3 |
User | Count |
---|---|
15 | |
9 | |
6 | |
3 | |
3 |