How to create MTD YTD QTD

HI @Manoj @Max @abacon @cx-ex-quicksight @consultantcon @quicksightenthusiast

I want to calculate total followers from starting day of every month to current date (for example: if current date is 16th august 2023 and i want to see the followers month wise from starting day of the month, to 16th of every month and this 16th should be updated dynamically by setting as today’s date )
Basically if i choose months granularity, then data should be displayed from starting day of the month till 16th of that month itself , for all months separately

currently i have created a parameter
data is displaying correctly for the formula i have used for MOM/QOQ/YOY

Need this formula to update and link MTD/QTD/YTD

Hello @Akshaymanjunath !

For the function that you made with a parameter, did you use an EndDate parameter?

You could use an end date parameter and set it to Today or now() .

It might be easier to help if you send the function that you create for you MOM/QOQ/YOY function.

Hi @duncan

I have created MOM/QOQ/YOY USING : ifelse(${MOM}=‘MOM/QOQ/YOY’,periodOverPeriodPercentDifference(sum(followers), date, MONTH, 1),count(followers))


HERE MOM, is a parameter which holds 2 dropdowns

  1. MOM/QOQ/YOY
  2. MTD/QTD/YTD

Also, i have added same formula to different date granularity as u can see here
when MoM/QoQ/YoY is selected, i’m getting the required output:

when MTD/QTD/YTD is selected i’m not getting the expected output

as u can see when i select MOM/QOQ/YOY then in the above formula upto:
“ifelse(${MOM}=‘MOM/QOQ/YOY’,periodOverPeriodPercentDifference(sum(followers), date, MONTH, 1),”
here its working fine as per the required dropdown (MOM/QOQ/YOY)
But when i select MTD/YTD/QTD it should display data from beginning of every month to current date only, (since i was unable to get mtd formula right i added another function to show that i want it to work if the first condition is not executed in the ifelse),

i.e if Mom/QoQ/YoY is not selected the the other funtion selected i.e , should be displaying MTD/QTD/YTD)

the other function is defined as:

for example if today’s date is 21st then regardless of month and year data should be displaying for 1st of every month to 21st of that month itself

MTD/QTD/YTD
1 jan 2023 to 21 jan 2023
1 feb 2023 to 21 feb 2023
1 march 2023 to 21 march 2023

so need this function in the else condition when I select MTD/QTD/YTD

Hello @Akshaymanjunath !

Could you try using the periodtodate functions for this?

Using your above style, you could do something like this:
ifelse(${MTD}=‘MTD/QTD/YTD’, periodtoDatesSum(abs{followers}, {date}, MONTH, now()), count(followers)

You can technically omit the now() function and it will default to today’s date

Hi @duncan

I tried using the below formula as u had suggested
Formula: ifelse(${MOM}=‘MTD/QTD/YTD’, periodToDateSum((abs(followers)), date, MONTH), count(followers))


image
data is displayed from 1st of that month to 23rd of this year and this month
even after omitting now() which you suggested i’m not able to get the desired output

I have attached the final / required output in the last 2 images)

Actually i don’t want followers from start of every month to this years current date, I want followers from start of every month to the day of today’s date in their particular months itself.
below is the clear picture of the requirement

As you can see here when MTD button is selected then data is displaying for each month from 1st to 23rd of that month and year itself (since today is 23)

When its split to day wise, we can see that calculations are getting performed till 23 of that month and year itself
But in QuickSight when its split to day wise after applying the formula we can still see that its getting calculated after 23 of the month


when broken down we can see the calculation till 23 only of every month

Hello @Akshaymanjunath , something you could try would be to add a calculated field to create a new column for the day value of the date using something like truncDate({Date}, “DD”). You can add it to the table and hide it from displaying.

Then create a parameter that would set to the current day in the same format. Once completed, filter the table by the calculated function for the day to be less than or equal to the value in the parameter.

@Akshaymanjunath

We have not heard back from you regarding your question. We would still like to help. If we do not hear back in the next 3 days, we will archive the question

Hi @duncan @Max

Even after truncating the date field and hiding it in the pivot table i’m not getting the expected result
image
created parameter and filtered table as well

here is the dataset could you please do it for me
https://drive.google.com/drive/folders/1eAweTRSFDJ3othtWsDRHtJwfiPOqpoWM

Hello @Akshaymanjunath ,

I can not access your dataset. When you used the calculation above, what is the result that you are getting and why is it not what you expected?

In the community it is important to remember not to share non-anonymized or redacted access to your proprietary data