Whenever I try to Truncate the date to year, quarter, week .
I want the x-axis date to show in their respective formats like for Year:2022,Quarter:Q3,2022 etc. But it shows only in one date format that we specify.
Is there a way to dynamically change based on year, quarter etc.
Hello @SanthoshV, I want to clarify something first. I am assuming you are using the “Period” control value to set a parameter which will determine the value returned within an ifelse statement in a calculated field, correct? That field will be used as the x-axis in a line chart.
The only issue with this is, no matter which one you select, the Aggregate for that field well will not change, just the returned value. There are 2 options you can try.
One would be to pass values in through your SQL to get a Date value for each of the formats you want. Then, using this drill down layer documentation, you can add them as drill downs in your visual with predetermined aggregations on each.
Another option would be to have 4 different line charts layered on top of each other in the free-form format. You can use the control to determine which will show and which will hide with calculated fields displaying the x-axis for each. This allows you to aggregate the returned value differently. You may not even need calculated fields in this instance, but just aggregate your original date field each time to match the Period selected.