Forum Discussion
JCortez
11 months agoFrequent Visitor
Date Calculation
I have these SQL tables below and I am trying to calculate that date difference between these two columns: Client_Assessment.clas_date - Client_Program.start_date I am getting this error below,...
- 11 months ago
Hi JCortez
See if this Calculated Column DAX Query helps you
DateDiff_Days = VAR StartDate = CALCULATE ( MIN ( Client_Program[start_date] ), FILTER ( Client_Program, Client_Program[client_id] = Client_Assessment[client_id] && Client_Program[serv_id] = Client_Assessment[serv_id] ) ) RETURN IF ( NOT ISBLANK(StartDate), DATEDIFF(StartDate, Client_Assessment[clas_date], DAY), BLANK() )I have attached a sample PBIX file. I have tested this code and built it without any relationships, since I’m not sure how you have set them up in yours. Feel free to play around with it and see if it works for you as well.
kushanNa
11 months agoSuper User
Hi JCortez
See if this Calculated Column DAX Query helps you
DateDiff_Days =
VAR StartDate =
CALCULATE (
MIN ( Client_Program[start_date] ),
FILTER (
Client_Program,
Client_Program[client_id] = Client_Assessment[client_id]
&& Client_Program[serv_id] = Client_Assessment[serv_id]
)
)
RETURN
IF (
NOT ISBLANK(StartDate),
DATEDIFF(StartDate, Client_Assessment[clas_date], DAY),
BLANK()
)
I have attached a sample PBIX file. I have tested this code and built it without any relationships, since I’m not sure how you have set them up in yours. Feel free to play around with it and see if it works for you as well.