Forum Discussion
Comparing values in same column in Power BI
Hey JH-PowerBI-1 ,
what you are looking for is not as simple as we might want, please allow me to direct you to this blog, here I used more words: Navigating Tabular Tables - Previous Row - Mincing Data - Gain Insight from Data (minceddata.info)
Next to that, you may want to rethink your 1 and 0 approach, my approach sorts the rows inside a group (Column Person) Descending, meaning the most recent row is flagged with 1. This provides the same possibilities, filtering for all rows that contain the value 1.
Here we go ...
The data, (please be aware that the date of the first row represents the 6th of January and not the 1st of June 🙂 )
It's mandatory that the data type of the column Column Dates is Date
Then I group the rows by the column Column person and select the Operation All Rows
Then it becomes a little hacky as it is necessary to tweak the Group By transformation in the Advanced Editor, doing that will prevent opening the Group By dialog once again, as the tweak can not be rendered by the dialog.
Nevertheless here we go ...
In the advanced editor I identify the Group By transformation:
Then I get rid of some not needed code
Then I replace the _ (the underscore) with some code. The underscore represents a table. The object represented by the underscore is depending on a context, here it is the table created by the Group By transformation.
The code that I use to replace the _ is this:
Table.AddIndexColumn (Table.Sort( _ , {{"Column Dates" , Order.Descending}}) , "Most Recent Date" , 1 , 1)
the complete line including the remaining part ...
each Table.AddIndexColumn (Table.Sort( _ , {{"Column Dates" , Order.Descending}}) , "Most Recent Date" , 1 , 1), type table }}
The the table can be expanded:
And the result, now the most recent date for each person is flagged with the value one and can be used to filter the row:
Hopefully, this is what you are looking for.
Regards,
Tom
Best regards! interesting... I managed to do it and it serves as a Date Ranking.
I mean, I use the DAX RANKX to create a Ranking of dates and know which is the first and last date of a group of users, for example I could have the last start date of session and the first, or play with that ...
But my problem lies in this:
I need to know per user the number of days of difference between the date RankX 1 and RankX 2. But the dates are in the same column, one below the other.
Do you have any idea how to approach that please?