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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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