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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Need Help to Show values of previous Quarter based on selection

HI @PBCommunity 

I spend couple of hours to resolve this but didn't succeed.

I wanted to show the sum of values of prvious quarter based on slicer selection using selected value.

This is how i tried to implement.

I have created a measure to give the previous quarter number as per user selection

=> Previous Quater = SELECTEDVALUE(Sheet1[quater])-1
and then use this result in other measure to get some of values of the prevouious month

=> cal measure =
CALCULATEsum(Sheet1[amount]),FILTER(Sheet1,Sheet1[reason]="A" && Sheet1[quater]=[Previou Quater]))

This will work fine if i remove -1 from the previous quater and it shows the correct sum of selected value but when i put -1 as shown above for previous month i gives blank.

Here is the data set and output in both case without -1 and with -1.

ZaheerAlam11_0-1656379717261.png


output without -1

ZaheerAlam11_1-1656379813806.png

output with -1

ZaheerAlam11_2-1656379848908.png

Please help me to resolve this thanks.






1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

pls try this

Measure 2 = 
VAR _q=max('Table'[quarter])
return CALCULATE([Measure],FILTER(all('Table'),'Table'[quarter]=_q-1))

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
ryan_mayu
Super User
Super User

@Anonymous 

pls try this

Measure 2 = 
VAR _q=max('Table'[quarter])
return CALCULATE([Measure],FILTER(all('Table'),'Table'[quarter]=_q-1))

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hello, The above provided details are helpful. Could you please help how to edit it if the current quarter is 2024Q1 and hence previous quarter should be 2023Q4?

Hi @ryan_mayu , Please let me know how will you calculate Previous Year QTD the same way. Thanks

Anonymous
Not applicable

Thanks @ryan_mayu  for help.This solution works for me

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , Try like

CALCULATE( sum(Sheet1[amount]),FILTER(all(Sheet1),Sheet1[reason]="A" && Sheet1[quater]=[Previou Quater]))

 

Better to have a separate Qtr/date Table

This Qtr = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Qtr]=max('Date'[Qtr])))
Last Qtr = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Qtr]=max('Date'[Qtr])-1))

 

The best is have a Rank on Year Qtr column

 

Qtr Rank = RANKX(all('Date'),'Date'[Year Qtr],,ASC,Dense)  //column

 

Measure 
This Qtr = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])))
Last Qtr = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])-1))

 

Power BI — Qtr on Qtr with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
https://www.youtube.com/watch?v=8-TlVx7P0A0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks @amitchandak  for the solution.I have already subscribed your channel and like the way you are helping community.

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.