Reply
WMart_AMS
Frequent Visitor

Re: Get value from previous grouped index number in a new column (Powerquery or DAX)

Hi!

 

Can somebody help me out with a solution to generate the column "previous Index OVerall_avg_Score" as presented in the image below. Preferably i'd like to get this result in PowerQuery, but DAX solutions are also welcome. The dataset is presented below the image.

 

I've looked up various solutions, but they are mainly focused on date-related measures or they do not work with a group of index numbers as shown in this example. Your help is greatly appreciated!

 

WMart_AMS_0-1743083580856.png

 

 

IndexProject_CodeOverall_Avg_Score
173041001712
173042100562,4
173042100321
173042100530
173042100330
273041001713
273042100562,3
273042100322,4
273042100530
273042100330
373041001712,4
373042100562,2
373042100322,4
373042100530
373042100330
473041001711,5
473042100561,6
473042100322
473042100530
473042100330
573041001713
573042100562,7
573042100322,8
573042100530,6
573042100332,1
1 ACCEPTED SOLUTION
Cookistador
Resolver III
Resolver III

I had to do something similar a few months ago

 

With Power query:

You create a column called PreviousIndex: Index -1

Then you make a self join using Index & Project Code AND PreviousIndex &  Project Code

 

In dax:

You create a calculated columns with a PreviousIndex, you create two calculated column in your source table:  Index & Project Code  and in the calculated column: reviousIndex &  Project Code

You link your two tables and then you use 

NATURALLEFTOUTERJOIN(SourceTable, CalculatedTable)

 

 

View solution in original post

2 REPLIES 2
Cookistador
Resolver III
Resolver III

I had to do something similar a few months ago

 

With Power query:

You create a column called PreviousIndex: Index -1

Then you make a self join using Index & Project Code AND PreviousIndex &  Project Code

 

In dax:

You create a calculated columns with a PreviousIndex, you create two calculated column in your source table:  Index & Project Code  and in the calculated column: reviousIndex &  Project Code

You link your two tables and then you use 

NATURALLEFTOUTERJOIN(SourceTable, CalculatedTable)

 

 

Thanks so much, the PowerQuery solution you provided worked! This issue bothered me for a long time already. Thank you so much!

avatar user

Helpful resources

Announcements
March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)