Hi,
We currently have a calculated field that performs the following:
#This is an expression of the average margin in percentage the month that ends on endM1
#This could for example be 50% for the month of March if the endM1 parameter is set to March 31st 2023
((sumIf({margin},{date} >= truncDate(‘MM’, ${endM1}) AND {date} < truncDate(‘MM’, addDateTime(1, ‘MM’, ${endM1}))) /
sumIf({revenue},{date} >= truncDate(‘MM’, ${endM1}) AND {date} < truncDate(‘MM’, addDateTime(1, ‘MM’, ${endM1}))))
/
#This is an expression of the average margin in percentage for the full year prior to the endM1 date.
#This would in the same example as above be then the margin in % for the full year of 2023. (If endM1 is set to Match 31st 2023).
(sumIf({margin},{date} >= truncDate(‘YYYY’, addDateTime(-1, ‘YYYY’, ${endM1})) AND {date} < truncDate(‘YYYY’, ${endM1})) /
sumIf({revenue},{date} >= truncDate(‘YYYY’, addDateTime(-1, ‘YYYY’, ${endM1})) AND {date} < truncDate(‘YYYY’, ${endM1})))) - 1
This works well and as intended and shows whether there has been a margin growth compared to the previous year.
However, the question is: would one in quicksight be able to show this in a bar chart over time? So that each month in the chart executes this type of calculation dynamically compared to the month in the chart field (e.g. January 2023, February 2023, March 2023, and so on.). In this case, all of them should calculate the margin growth in (%) against the entire previous year. I’ve also added just an illustrative image of how this would be calculated and what should display.
Perhaps there is some way using table calculations but we’ve been unable to find a way here. Any help is appreciated.
On this note, it seems a great thing in calculated fields would be the ability to access a visuals field well values. For example dates in the topic above being able to dynamically write the expected outcome yourself.