Forum Discussion

misul's avatar
misul
Helper I
8 years ago
Solved

Count based on another column

  Hi PBI Community, I am trying to solve the following issue. I want to count how many different routes does a Customer follow. In other words, a distinct count of the column "Route" per Customer. ...
  • ChrisMendoza's avatar
    8 years ago

    hello misul,

     

    You could try:

     

    Column = 
    CALCULATE(
       DISTINCTCOUNT(Table1[Route]),
       ALLEXCEPT(Table1,Table1[Customer])
       )
  • misul's avatar
    misul
    8 years ago

    ChrisMendoza Correct, the intention is to use DistinctCountofRoutes as a slicer.


    When I use the calculated column, the values are summed. So I put the column to "Don't Summarize" and it seems to work now. Thanks!

     

    Calculated Column: 

    Column = 
    CALCULATE(
       DISTINCTCOUNT(Table1[Route]),
       ALLEXCEPT(Table1,Table1[Customer])
       )

     

    Measure:

    Measure= 
    CALCULATE(
       DISTINCTCOUNT(Table1[Route]),
       ALLEXCEPT(Table1,Table1[Customer])
       )

     

    I realised that the same formula can be used as a measure too. But as measures cannot be used in Slicers. I will stick with Calculated Column (without summarizing it).