Forum Discussion
Dynamic Date Slicer | Calculated Columns for Current Quarter and Current Year
Hi all,
I'm having trouble using DAX to creae a dynamic date column in my date table. I am able to do this in Power Query, but would prefer to just do it in DAX so its a bit more simple for the client to take a look at.
I have my date table created like this:
Thanks!
- Anonymous5 years ago
Hi Anonymous
I think your requirement is to build two dynamic Year and dynamic Quarter to show current value or actual value by selection. Unfortunately, calculated column couldn't show dynamic results like this. I think you can try measure. Measure supports to show dynamic results by selections.
For reference:
Calculated Columns vs Measures
What is the difference between Power BI calculated columns and measures?
Build a table, then create a slicer by this table.
Measures:
Dynamic Year = VAR _SELECTION = SELECTEDVALUE(Selection[Selection]) RETURN IF(_SELECTION = "Actual",YEAR(MAX(dimCalendar[Date])),YEAR(TODAY()))Dynamic Quarter = VAR _SELECTION = SELECTEDVALUE(Selection[Selection]) RETURN IF(_SELECTION = "Actual",QUARTER(MAX(dimCalendar[Date])),QUARTER(TODAY()))Result is as below.
Select "Actual":
Select "Current":
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi Anonymous
I think your requirement is to build two dynamic Year and dynamic Quarter to show current value or actual value by selection. Unfortunately, calculated column couldn't show dynamic results like this. I think you can try measure. Measure supports to show dynamic results by selections.
For reference:
Calculated Columns vs Measures
What is the difference between Power BI calculated columns and measures?
Build a table, then create a slicer by this table.
Measures:
Dynamic Year = VAR _SELECTION = SELECTEDVALUE(Selection[Selection]) RETURN IF(_SELECTION = "Actual",YEAR(MAX(dimCalendar[Date])),YEAR(TODAY()))Dynamic Quarter = VAR _SELECTION = SELECTEDVALUE(Selection[Selection]) RETURN IF(_SELECTION = "Actual",QUARTER(MAX(dimCalendar[Date])),QUARTER(TODAY()))Result is as below.
Select "Actual":
Select "Current":
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.