Power BI versions of SQL's ROW_NUMBER
I've come to rely quite heavily on SQL's ability to apply an ordered rank to bins of data with relative ease, by using PARTITION BY ORDER BY. Be it ROW_NUMBER(), DENSE_RANK() etc, with one line i can establish an order to something whcih then becomes a powerful means of filtering my data when loaded into Power BI.
I've always been curious if there is a way to do this in Power BI natively? I find myself teaching others at work how to use Power BI, who don't have access or knowledge to write SQL, so then I end up writing them something to then import.
For example, determine the latest date something was inspected, per asset. in SQL, I'd write
(DENSE_RANK() OVER (PARTITION BY [the thing] ORDER BY [InspectionDate] DESC)
which I coudl then filter for '1' to show me the latest dates of the all of the things.
Thanks
Posted Jun 14, 2022, 7:14 AM UTC
Yeah have a look at rankx, it's not a drop in replacement for window functions in sql but it fits your use case
Thanks man, appreciated