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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
AFra
Helper III
Helper III

Distinctcount from table A related to id from table B

Hi, 

 

I have two tables : 

- table A contains ID for each family, ID for each person, and birthdates

- table B contains ID for each family 

The two tables have a many (table A) to one (table B) relationship based on ID for each family 

 

I need to create a column in table B with the number of persons by family, so I created : 

NBR_OCCUPANTS =
var nombre = CALCULATE(
                            DISTINCTCOUNT(A2[IDENTIFIANT_LOCATAIRE]),
                            GROUPBY(A1, A1[IDENTIFIANT_MENAGE]))
return
if(nombre<9, CONCATENATE(nombre, " pers."), "9 et +")
 
it works nicely, but then I need also a column with all the children by family. I tried to apply the same logic with an extra filter on birthdate, but it gives me an error : "Une dépendance circulaire a été détectée : A1[Colonne], A1[NBR_OCCUPANTS], A1[Colonne]." 
 
Can someone help me please? 
3 REPLIES 3
MFelix
Super User
Super User

Hi @AFra ,

 

The connection is not working properly can you please share the link again.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix , 

here's the link : https://we.tl/t-HgmzDfTeyV

 

Hi @AFra ,

 

Try adding the following columns in dax:

NBR_OCCUPANTS = 
var nombre = CALCULATE(COUNTROWS(TABLEA))
Return
if(nombre < 9, CONCATENATE(nombre, " pers."), "9 et +")

NBR_OCCUPANTS_enfant = 
var nombre = CALCULATE(
    COUNTROWS(
        FILTER(ADDCOLUMNS(TABLEA,"Age", DATEDIFF(TABLEA[DATE_DE_NAISSANCE], TODAY(), YEAR)), [Age] <18)
        )
    ) + 0
Return
if(nombre < 9, CONCATENATE(nombre, " enfants"), "9 et +")

 

No error for circularity will be returned.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.