Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hey there,
I have following situation which I couldn't resolve yet:
I want to compare each row with the previous row.
If Colour and Previous Colour are both the same as in the row before I want to skip to the next row automatically and try it again.
If they are not the same, in an additional column it should add the value "1"
ID | Colour | Previous Colour | Index |
126443 | Red | Green | 1 |
123456 | Blue | Red | 2 |
175332 | Blue | Red | 3 |
765432 | Yellow | Blue | 4 |
733511 | Green | Yellow | 5 |
531534 | Blue | Green | 6 |
Something like:
if ((PrevColour(index-1) = PrevColour(index) && Colour(index-1) = Colour(index))
then jump to index+1
else type "1" in new column
I'd appreciate any help. Kind regards 🙂
Jama1234
Solved! Go to Solution.
1. Add a new column: Index2 as an index column starting at 2 (one more than column Index)
2. Do a self join (Merge Tables) with Index and Index2 as the key joining columns. Kind of join is left outer
3. Expand the newly generated column to new rows.
4. Now you have duplicate columns in your table with values equal to the previous row.
5. Add a column that compares the current values with the previous values that are stored in the same row.
6. Remove unneeded columns
1. Add a new column: Index2 as an index column starting at 2 (one more than column Index)
2. Do a self join (Merge Tables) with Index and Index2 as the key joining columns. Kind of join is left outer
3. Expand the newly generated column to new rows.
4. Now you have duplicate columns in your table with values equal to the previous row.
5. Add a column that compares the current values with the previous values that are stored in the same row.
6. Remove unneeded columns
It worked really well.
Thank you!!
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
10 | |
7 | |
7 | |
6 | |
6 |