Forum Discussion
prady2581
3 years agoHelper I
Allselected not considering the date filter context
I use below dax code to calculate % of client survyes to the total survey count received.
% Contribution of clients =
DIVIDE(
COUNT(
'Raw data'[clientname]),[Client_count_All])
Client_count_All is a measure =
CALCULATE(
COUNT('Raw data'[clientname]),ALLSELECTED('Raw data')
)
When a table matrix visual , i put the client name and total surveys then % Contribution of clients and 1 date slicer it gives the correct figures. the moment i add month year as column in the table matrix it is not giving the correct figures. i think it is adds up the total for jul'22 and aug'22 and then it takes this amount as total count
I want this measure to accept all context from slicers or and on table matrix ( in table matrix row will be always client name and column will be either month, or quarter from the date dim table). please provide some guidance on how to fix this.
this is correct
| date slicer | ||||||
| 01-07-2022 | 31-Jan-23 | client | total surveys | total count | % contribution | |
| a | 45 | 2000 | 2% | |||
| b | 30 | 2000 | 2% | |||
| c | 14 | 2000 | 1% | |||
| d | 3 | 2000 | 0% | |||
| … | 56 | 2000 | 3% | |||
| 98 | 2000 | 5% | ||||
| total | 2000 | 100% |
this is not correct
| date slicer | total surveys | % contribution | ||||||
| 01-07-2022 | 31-Jan-23 | client | Jul-22 | total count | % | Jul-22 | total count | % |
| a | 45 | 1200 | 4% | 34 | 1200 | 3% | ||
| b | 30 | 1200 | 3% | 67 | 1200 | 6% | ||
| c | 14 | 1200 | 1% | 23 | 1200 | 2% | ||
| d | 3 | 1200 | 0% | 37 | 1200 | 3% | ||
| … | 56 | 1200 | 5% | 44 | 1200 | 4% | ||
| 98 | 1200 | 8% | 39 | 1200 | 3% | |||
| total | 1200 |
1 Reply
- amitchandakSuper User
prady2581 , In that case you should use remove filters of client
Client_count_All =
CALCULATE(
COUNT('Raw data'[clientname]),removefilters('Raw data'[client] )
)Learn Power BI: All, allselected, removefilters,allexcept- https://www.youtube.com/watch?v=cN8AO3_vmlY&t=24270s