Power BI Count number of repeating ID

2020-07-27 04:18发布

How do I count repeating ID? I want to put it on the new column, it really doesn't matter if the number of total is repeating example like (if out come is this then better):

==========|=
   10327  |2
   10327  |2
   10328  |3
   10328  |3
   10328  |3

RepeatingID

标签: powerbi
1条回答
欢心
2楼-- · 2020-07-27 04:57

Use a calculated column like this:

NrOfOccurrences = CALCULATE(
    COUNT([OrderID]); 
    FILTER(Orders; [OrderID] = EARLIER('Orders'[OrderID])))

From bottom to top:

  • FILTER gives you a table per row that has all rows with the same OrderID
  • COUNT would count the number of OrderIDs, effectively the number of rows
  • CALCULATE puts them together, so that the number of rows in the relevant FILTER table is counted;

For example this is a screenshot of a manually entered table:

example table

查看更多
登录 后发表回答