The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi !
Please, help with this task:
I have 4 simple tables with some relations like in screenshot. How can I build result table?
Result description:
For C1 category we have 2 Contacts Co1, Co2. This Contacts took part into 2 Activities Call1, Call2. So, result for C1 category is 2.
For C2 category we don't have any Contacts. Due to this fact, we don't have any Activities.
For Non Seg category we don't have any Contacts too. Due to this fact, we don't have any Activities too. But, only in this case, we must calculate result like "All Activities - Activities for Categories". So, result for Non Seg Category is 3-2=1
Also, result table is matrix, which have categories from Category table in columns!
Solved! Go to Solution.
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/
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 ?
User | Count |
---|---|
65 | |
62 | |
60 | |
53 | |
28 |
User | Count |
---|---|
181 | |
82 | |
67 | |
48 | |
44 |