# Getting value of previous quarter and comparison

Member

Hello Team,

I have a date column named 'Fiscal quarter start date' and another Beast mode with calculated value for 'Customer Survey'

I want to create a beast mode in which I will compare the Customer survey of the Current Quarter with the second last quarter. I tried to create a Case statement but unable to get results card is not loading any results. Please help

Tagged:

• Coach

@MayaU_01 - I think you should look at my response to another recent question.

I showed the way I like to do what I refer to as trends. Comparing year to previous year and the year before that. I use the same calculation formula to compare previous quarters across multiple years.

Using this calculation, add another line that says:

and QUARTER('date') < = QUARTER(CURRENT_DATE())

And you will have a comparison of quarter to previous quarter. And quarters of the year to quarters of previous years.

What I don't show on that other thread is that I use a similar formula to then represent the difference or delta between them. Take the result of one quarter and subtract from the next and you get the difference. Take that difference over the previous total and you get the percentage of increase or decrease relative to the previous quarters.

This then lets me setup a table view or a bar chart, line chart, etc….with comparisons next to each other. When I take the above formula for difference and put it over the previous total, I get the percentage of increase or decrease.

.25 or 25% means a growth over the previous period of 25%.
Then I set up a table chart that has columns for

PY QTD {whatevers} | CY QTD {whatevers} | CY QTD Difference | CY QTD % of Change | etc.

** Did this solve your problem? Accept it as a solution! **

• Coach

Agree with @ArborRose, you'll need Beast Modes for each quarter and then compare between them. Just be aware that the `QUARTER` formula will work for the Gregorian Calendar, if you need to use a fiscal calendar that does not goes from January → December, then you'll need to adjust to account for that.

• Coach

Whenever I'm doing Period over Period analysis I will structure my data with my own custom date dimension dataset. You can then define how the offsets are and allows you to more easily filter your datasets so that you can look at this quarter but also have records for last quarter.

I've done a write up on this approach here:

**Did this solve your problem? Accept it as a solution!**
• Coach

You would want to use the Lag Windows Function in order to get the previous value.

1. LAG(SUM(`surveyvalue`)) OVER (ORDER BY `fiscalquarterdate`)

It's also worth pointing out that the Flex Table card is a great card for showing a previous value next to a current value. It's highly configurable to show a combination of values, bar graphs, percent changes and directional indicators. Here is the KB article:

https://domo-support.domo.com/s/article/360043429073?language=en_US

**Check out my Domo Tips & Tricks Videos

**Make sure to any users posts that helped you.
• Member

Hi,

I have used this method of LAG, but using this i am getting value of previous quarter in this quarter which is i think is the task of this function.

I may have explained the question wrong.

I thought to use that value but it will not help.

My question is - I have columns, Client, Mydate column, Survey Value (A Beast mode).

I am making a table view - with client in first column then add last 4 quarters of Survey value in the next 4 columns and then make a last column in which I am writing a beast mode which is - If the current quarter survey value is greater than survey value of second last quarter then 'Good' If decreased then 'BAd' If same then 'Same' If there is value in last quarter but no value in this quarter then 'No response'

CASE WHEN `Survey`> LAG (`Survey`, 2 ) OVER (ORDER BY `Fiscal Quarter Start Date`) THEN 'Increased'
`Survey`< LAG(`Survey`,2) OVER (ORDER BY `Fiscal Quarter Start Date`) THEN 'Decreased'
Else 'Same'
END

this beast mode is not helping and I am unsure that what else can help me.

• Coach

@MayaU_01 - I think you should look at my response to another recent question.

I showed the way I like to do what I refer to as trends. Comparing year to previous year and the year before that. I use the same calculation formula to compare previous quarters across multiple years.

Using this calculation, add another line that says:

and QUARTER('date') < = QUARTER(CURRENT_DATE())

And you will have a comparison of quarter to previous quarter. And quarters of the year to quarters of previous years.

What I don't show on that other thread is that I use a similar formula to then represent the difference or delta between them. Take the result of one quarter and subtract from the next and you get the difference. Take that difference over the previous total and you get the percentage of increase or decrease relative to the previous quarters.

This then lets me setup a table view or a bar chart, line chart, etc….with comparisons next to each other. When I take the above formula for difference and put it over the previous total, I get the percentage of increase or decrease.

.25 or 25% means a growth over the previous period of 25%.
Then I set up a table chart that has columns for

PY QTD {whatevers} | CY QTD {whatevers} | CY QTD Difference | CY QTD % of Change | etc.

Agree with @ArborRose, you'll need Beast Modes for each quarter and then compare between them. Just be aware that the `QUARTER` formula will work for the Gregorian Calendar, if you need to use a fiscal calendar that does not goes from January → December, then you'll need to adjust to account for that.