Forum Discussion
Calculate for missing category (DAX)
- 5 years ago
Hi, Vitaliy
Please check the below picture and the sample pbix file's link down below, whether it is what you are looking for.
Activity Count =
IF (
SELECTEDVALUE ( Catetory[ID] ) = "Non Seg",
CALCULATE ( COUNTROWS ( ContactActivity ), ALLSELECTED ( ContactActivity ) )
- CALCULATE (
DISTINCTCOUNT ( ContactActivity[Callid] ),
ALLSELECTED ( Catetory )
),
IF (
NOT ISBLANK ( SELECTEDVALUE ( Catetory[ID] ) ),
COALESCE ( DISTINCTCOUNT ( ContactActivity[Callid] ), 0 ),
BLANK ()
)
)https://www.dropbox.com/s/o3665ejobsuhyhe/vitaliy.pbix?dl=0
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: https://www.linkedin.com/in/jihwankim1975/
Hey Vitaliy ,
please try with the following measure:
Acitvities =
VAR vActivities = IF( MAX( Category[Id] ) <> BLANK(), COUNTROWS( ContactActivity ) )
VAR vAllActivities =
CALCULATE(
COUNTROWS( ContactActivity ),
ALL( Category[Id] )
)
VAR vActivitiesForCategories =
CALCULATE(
COUNTROWS( ContactActivity ),
Category[Id] <> BLANK()
)
RETURN
IF(
ISINSCOPE( Category[Id] ) && MAX( Category[Id] ) = "Non seg",
vAllActivities - vActivitiesForCategories,
vActivities
)
This will produce the following result:
You can check my file here:
https://www.swisstransfer.com/d/e3eeb216-2ce4-491a-bd3d-0cb4f39794d6
Thanks for your response!
I think this is not quite what I need, cause if we add some new calls into Activity table (for example Call4, Call5) and this calls would be without contacts (no rows in ContactActivity table for this new calls) - result would be the same as you wrote. But, for my case, result must be: C1 == 2, C2 == 0, Non Seg == 3. Or I'm wrong ?