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 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:
Solved! Go to Solution.
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 Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
---|---|
13 | |
2 | |
2 | |
1 | |
1 |
User | Count |
---|---|
20 | |
3 | |
2 | |
2 | |
2 |