Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Summarize with countX

I have a table(Table A) with following fields

 

VarId     CaseId    Activity

 

This table is linked to another table(Table B) on CaseId. Now I need to create a calculated table which should contain following fields:

 

Var Id         Activity       TotalCount

 

So this calculated table will contain total count of each activity per variant.

 

Also, selecting a VarId in a table visual , should update this calculated table to show the count of activities only for selected VarId (there can be multiple selection too). I have used below DAX query to create the table.

 

VarAndActivityCount =
SUMMARIZE('TableA', TableA[Var Id], TableA[Activity], "TotalCount", Countx(TableA,IF(CONTAINS(ALLSELECTED(TableB[Var Id]),TableB[Var Id],TableA[Var Id]),1,0)))
 

It is giving correct count for each activity when all var Ids are selected but when I select few var ids, number is not matching with the expected count 

 

Can anyone please help me to resolve this issue.                        

2 Replies

  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi Anonymous ,

    To understand your scenario better, you'd better show some data sample which could reproduce your scenario and your desired output so that we could help further on it.

    Or, ideally, share the pbix (beware of confidential data).

    Best  Regards,

    Cherry

     

  • Hi Anonymous ,

    I tried replicating your issue with some sample data I made. Found it was working as expected.

     

    On a high level, May be, what you can check is the data type of the coumn Var Id and also if there are any reationships built based on Var Id Column.

     

    These two might affect the way it works.

     

    For more detailed clarification, you might have to share some sample data. If possible, PBIX file

     

    Cheers!