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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.