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.
Is this possible to do in a calculated column?
Below is the table and on the right is the desired Count column.
Thank you for your time!
Solved! Go to Solution.
@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!
Column = CALCULATE( DISTINCTCOUNT(Table1[Route]), ALLEXCEPT(Table1,Table1[Customer]) )
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).
What I would do is a global column :
count = COUNTROWS(Table)/CALCULATE(COUNTROWS(Table);ALL(Table))
And then you add both the customer column and the new count column to a Card Box
It will display Customer + Count of distinct
Create a calculated column
DistinctRoute by customer = VAR CurrencyCustomar = 'Table'[Customar] RETURN CALCULATE(DISTINCTCOUNT('Table'[Route]); FILTER(ALL('Table');'Table'[Customar] = CurrencyCustomar))
@shapkovromanBI My database is very big, and this formula takes a very very long time to run. This isn't ideal.. formula is still being calculated, it has been a few minutes now.
Update after 10 minutes .. still running. This formula can't be used ..as it takes more than 10 minutes time to run on my database.
Any further ideas?
Thanks for your help. But I need the Distinct Count as a Column/Measure so that I can use this as a slicer later on.
When I select Distinct Count = 1, show me all the customers which are having 1 route (i.e Customer C,D,E)
When I select Distinct Coutn =4, show me all the customers which are having 4 Routes. (i.e. Customer A)
Any further ideas?
@ChrisMendoza Thanks for your idea. This is working in my dummy file. But not in my database (which has much more records).
There are only 15 routes available. But the measure you gave is returning values like - 3000, 200 etc.
Is it summing the column? I wouldn't imagine that you would actually use the calculated column for anything except for some math operation or a slicer.
Based off your response to someone else, your intention is to use a slicer to filter the data set, so the slicer is generating > ~15 routes which you did not expect?
Since you are specifying it takes more time to a computer. Can you split the main table to have only "customer" and "route" and later join the new table by the customer and give appropriate direction?