Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
kdesai
Frequent Visitor

Issue with MINX DAX Calculation

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

Capture.PNG


I am expecting the output to be this

Capture1.PNG

1 REPLY 1
d_gosbell
Super User
Super User

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)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.