Forum Discussion
Age Calculation in DAX Incorrect for Previous Months/Years
- 1 year ago
Hiiii nmhung49
Age_Week =
VAR SelectedDate = MAX('Date'[Date]) -- Get the latest date in the selected time period
VAR StartDate = SELECTEDVALUE('YourTable'[Start_Date]) -- Replace with your actual date column
VAR AgeInDays = DATEDIFF(StartDate, SelectedDate, DAY)
VAR AgeInWeeks = DIVIDE(AgeInDays, 7)RETURN AgeInWeeks
If this helps, I would appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!
Hi nmhung49 ,
It seems like there was some problem on DAX measure. The year/month slicer at the top is from the Calendar table and I noticed that the measure Qty_InV1 references Calendar table.
This measures uses ALL (Calendar) which will ignore the slicer and return all values.
You can instead use-
and then try filtering. You will get correct values.
Hope this helps!!
I have tried it, but it didn’t return the correct values. Thank you for your suggestion! Do you have any other ideas for this case? Any insights from others would also be greatly appreciated!
Thank you for your help.