Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
YukiK
Impactful Individual
Impactful Individual

Calculate not working for getting Quarter over Quarter values

Hi all,

 

I have a data model that has a fact table containing a measurement like sales amount. I have a calendar table whose grain is month, and the table doesn't have the date, but has relative period/month, quarter, quarter + year, etc.

 

I'm trying to get sales amount last quarter so as to get QoQ %, but the measure I created doesn't seem to work. The fact table is connected is at the month level on "Period" column to the calendar table on "Period" column.

 

I have a sales measure like this.

 

Sales amount = SUM(fact[sales amount])

 

 

And the QoQ measure that I'm trying to work out is like the following.

 

Sales amount last quarter =
VAR __CurrQuarter = MIN(calendar[relative_quarter]) -- unique for each quarter
VAR __SalesLastQuarter = 
    CALCULATE(
        [Sales amount],
        calendar[relative_quarter] = __CurrQuarter  - 1
    )
RETURN
__SalesLastQuarter 

 

 

But this measure only returns blank even though __CurrQuarter - 1 returns the correct values... Any help would be appreciated!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your data model looks like but please try the below.

 

Sales amount last quarter =
VAR __CurrQuarter =
MIN ( calendar[relative_quarter] ) -- unique for each quarter
VAR __SalesLastQuarter =
CALCULATE (
[Sales amount],
FILTER ( ALL ( calendar ), calendar[relative_quarter] = __CurrQuarter - 1 )
)
RETURN
__SalesLastQuarter


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your data model looks like but please try the below.

 

Sales amount last quarter =
VAR __CurrQuarter =
MIN ( calendar[relative_quarter] ) -- unique for each quarter
VAR __SalesLastQuarter =
CALCULATE (
[Sales amount],
FILTER ( ALL ( calendar ), calendar[relative_quarter] = __CurrQuarter - 1 )
)
RETURN
__SalesLastQuarter


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
YukiK
Impactful Individual
Impactful Individual

Okay, this worked! Using "FILTER()" around the condition was the trick. Though I don't fully understand why I needed that for this to work. It was my understanding that the interals would be the same with that of without "FILTER()".

 

Would you mind sharing your wisdom around this concept?

Hi, 

it is quite difficult for me to explain without seeing the model.

Thank you.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
YukiK
Impactful Individual
Impactful Individual

- I have a sales fact table whose grain is per month per row.

- I have a dimention calendar table whose grain is also per month per row.

 

What might be tricky is my calculation is for quarter level data.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors