Forum Discussion
PowerBI Countif Top to Row Question
I've been working with PowerBI for about a year or so now, and its such a powerful tool. But as an Excel native there are still things I find easier in Excel to do. One process I haven't been able to figure out in PowerBI is how to count from the top of a sorted dataset to the current row how many instances of a data point there is.
Example:
My dataset is sorted by date/time.
I want to create a key, where on this dataset sorted by the date field "LegEnd" in ascending order we count to that row how many times the Tractor_ID shows up.
Tractor 1072 shows up in the dataset twice, on the first row it shows up I want the count to show "1", and the second time I want the count to show "2". Then I will concatenate it with the Tractor_ID to create a squencing key "1072-1" and "1072-2" and so on.
In Excel I used to be able to simply create this formula in a new column and copy it down:
= [Tractor_ID] & "-" & countif( [Tractor_ID]A$1:Ax, [Tractor_ID] )
Can anyone help me with this?
Anonymous add a rank column and then use it to concatenate. Read here about ranking .How to use RANKX in DAX (Part 1 of 3 - Calculated Columns) - RADACAD
✨ Follow us on LinkedIn
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
2 Replies
- parry2kSuper User
Anonymous add a rank column and then use it to concatenate. Read here about ranking .How to use RANKX in DAX (Part 1 of 3 - Calculated Columns) - RADACAD
✨ Follow us on LinkedIn
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- AnonymousNot applicable
Thanks Parry. This worked for me.