Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello all,
I have a set of audit tables, which show changes over time to data.
I am trying to group by the users in a particular age range, but only count the row with the most recent record.
Could anyone point me in the direction of how this is possible in PowerBI?
A copy of the data set can be found here:
https://imgur.com/a/GJcb9wN
A sample workbook can be found here:
http://s000.tinyupload.com/?file_id=49799153102272249392
Many thanks for your time!
Solved! Go to Solution.
Hi @Anonymous ,
Had to think about how to approach this, but figured one out. First off, a big thank you for supplying a test pbix, that saves us a lot of time in helping you 🙂
Anway, I used the following measure:
Count Of Latest =
VAR _tempTable = ADDCOLUMNS(FILTER(test, test[ID] <> BLANK()), "IsLatest",
VAR _curID = [ID]
VAR _curDate = [date]
RETURN
IF(COUNTROWS(FILTER(ALL(test), test[ID] = _curID && test[date] > _curDate)) = 0, TRUE, FALSE))
RETURN
COUNTROWS(FILTER(_tempTable, [IsLatest] = TRUE()))
First, I create a temporary table that starts with a filtered version of the table (filtering out blanks, they are useless?) and adds a column "IsLatest" that returns True if that row of the temp table is the latest row for that ID and false if not. The return value is the count of rows that has IsLatest is TRUE. Putting this in your visual, results to this:
The PBIX can be found here:
https://1drv.ms/u/s!Ancq8HFZYL_aiIxHaIgcyrtlh1m6Bg?e=aFu6Yu
Does this suits your needs? Let me know if you have any more questions 🙂
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
Proud to be a Super User!
Hi @Anonymous ,
Had to think about how to approach this, but figured one out. First off, a big thank you for supplying a test pbix, that saves us a lot of time in helping you 🙂
Anway, I used the following measure:
Count Of Latest =
VAR _tempTable = ADDCOLUMNS(FILTER(test, test[ID] <> BLANK()), "IsLatest",
VAR _curID = [ID]
VAR _curDate = [date]
RETURN
IF(COUNTROWS(FILTER(ALL(test), test[ID] = _curID && test[date] > _curDate)) = 0, TRUE, FALSE))
RETURN
COUNTROWS(FILTER(_tempTable, [IsLatest] = TRUE()))
First, I create a temporary table that starts with a filtered version of the table (filtering out blanks, they are useless?) and adds a column "IsLatest" that returns True if that row of the temp table is the latest row for that ID and false if not. The return value is the count of rows that has IsLatest is TRUE. Putting this in your visual, results to this:
The PBIX can be found here:
https://1drv.ms/u/s!Ancq8HFZYL_aiIxHaIgcyrtlh1m6Bg?e=aFu6Yu
Does this suits your needs? Let me know if you have any more questions 🙂
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
41 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
36 | |
33 | |
18 | |
18 |