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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

6 REPLIES 6
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!




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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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