Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
NeZ_AL
Frequent Visitor

Count number of events when using three different related tables

I have 3 tables related to each other, the first is Total_Pol (here there is monthly frequency data identified as a subgrupo), in the second Category_Total table (there are geological details of subgrupo and other sub-categories) and the third table Master_Total (there is the detail to which grupo each subgrupo belongs to, coordinates, etc).

I joined the tables as follows because they have a lot of data between them.

 

NeZ_AL_0-1670992888744.png

 

Although the values come in subgrupo, it is only valid to know the total per month at the grupo level.

I am trying to obtain the number of active groups per month, for which it is considered that if at least one subgroup of each group is greater than 0, the group is considered active.

 

I used teh current formula:

 

Count_Group = if(sumx(total_pol, Total_Pol[VALUE_FIX])>0,CALCULATE(DISTINCTCOUNT(Total_Pol[VALUE_FIX]),GROUPBY(Master_Total,Master_Total[GRUPO])),0)
 
And get the following Table:
 
NeZ_AL_1-1670993077551.png

 

When i removed the SUBGRUPO FIELD from the table i get this:

 

NeZ_AL_2-1670993146599.png

 

And when i removed the GRUPO FIELD i get this:

 

NeZ_AL_3-1670993191977.png

 

I would like to have this at the end:

 

NeZ_AL_4-1670993615190.png

Hope that makes sense!   I'd be grateful for any help.

 

Best Regards,

 

 

 

 

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @NeZ_AL 

please try

Count_Group =
SUMX (
    CALCULATETABLE (
        VALUES ( Master_Total[GRUPO] ),
        CROSSFILTER ( Total_Pol[SUBGROUPO], Category_Total[SUBGROUPO], BOTH )
    ),
    IF (
        CALCULATE (
            SUM ( Total_Pol[VALUE_FIX] ),
            CROSSFILTER ( Total_Pol[SUBGROUPO], Category_Total[SUBGROUPO], BOTH )
        ) > 0,
        1
    )
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @NeZ_AL 

please try

Count_Group =
SUMX (
    CALCULATETABLE (
        VALUES ( Master_Total[GRUPO] ),
        CROSSFILTER ( Total_Pol[SUBGROUPO], Category_Total[SUBGROUPO], BOTH )
    ),
    IF (
        CALCULATE (
            SUM ( Total_Pol[VALUE_FIX] ),
            CROSSFILTER ( Total_Pol[SUBGROUPO], Category_Total[SUBGROUPO], BOTH )
        ) > 0,
        1
    )
)

Thank you very much.

It works perfectly.

 

Best regards,

Nestor

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.