Forum Discussion

ugux's avatar
ugux
Frequent Visitor
5 years ago
Solved

Dynamic calculated Column based on Dates

Hi,

 

I have a Dates table, and I added a Calculated column (called Period) based on YearQuarter column. This calc. column always show the last 4 Quarters, Last4_Quarter-1...etc, it is rolling Years we can say. It works fine now, and I created a lot of visuals and tables based on this "Period" column.

 

The problem is, that users want to change which is the ACT_Year, ACT_Year-1 ...etc...so they don't want to work the current data every time. For example they want to compare 2020 and 2019, but now in 2021_Q1 I can't do this.

I tried to use paramter but Calculated column not support paramters.

I tried with measure, and I can calculate ACT_Year, ACT_YEAR-1..etc with measure based on a Parameter, but it works only in I add the YearQuarter column too to the Table visual. But finally I want to summarize data only for ACT_YEAR,-1,-2..etc without any more detailed dates column.

How Can I do this, to let users to change the Period data?

 

I made the calculated column now like this where max_date is a measure always shows the max date in dates table:

 

Period =
var _MonthDiff = DATEDIFF(Dates[Date],max_date,MONTH)
Return
SWITCH(
TRUE(),
_MonthDiff>47,"ACT-4",
_MonthDiff>35,"ACT-3",
_MonthDiff>23,"ACT-2",
_MonthDiff>11,"ACT-1",
_MonthDiff>=0,"ACT")
 

Thank you in advance

1 Reply