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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Lookup Rating From Previous Quarter to See if Current Rating Has Changed

Hi,

 

I have a table containing ratings of different products from all quarters.

 

I want to be able to lookup the previous quarter rating (add that as a new column to my table) to do further calculations in the future, but I'm having trouble referencing the columns from my table variables.

 

Info: NewHelperQuarter is last quarter, [Rating] is string, and EARLIER is so that the filter selects all rows from that previous quarter.

 

Is there any way to make SELECTCOLUMNS return a single column instead of table? I remember @TomMartens talked about data lineage in this post Do any of you know how to solve this?

 

For example I have "Product A", I want the Q4 "Product A" to have the Q3 rating as an entry, the Q3 "Product A" to have the Q2 rating etc. for all quarters and all products (Product A - Z)

 

Thank you!image.png

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , if you have a date use Time intelligence. Else have separate table for Year Qtr and create a rank column on that, join back on year qtr

 

examples

 

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))


Qtr Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(ENDOFQUARTER('Date'[Date])))

Last QUARTER Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD( ENDOFQUARTER(dateadd('Date'[Date],-1,QUARTER))))
Last QUARTER Sales = CALCULATE(SUM(Sales[Sales Amount]),PREVIOUSQUARTER(('Date'[Date])))

 

new column

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

 

Measures
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))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Hi! Thank you for the help. I was just wondering do the examples sum all the sales from that quarter? Because my rating values are like "BBB" and I don't want to sum up the previous quarter.

 

For example I have "Product A", I want the Q4 "Product A" to have the Q3 rating as an entry, the Q3 "Product A" to have the Q2 rating etc. for all quarters and all products (Product A - Z for example)

 

Thank you!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.