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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Mikaseido1
Frequent Visitor

NEED HELP // ERROR AL CONTAR

Buenas noches, 

 

Estoy tratando de contar la columna con nombre numIdentificacionHogar, la cual contiene valores repetidos y se debe contar lo que no se repita.

 

Existe otra columna con nombre nombreTerritorio, que contiene una enúmeración de T1 a T12. Requiero contar en una medida independiente y sola todos los hogares de todos los territorios.

 

Al realizar una tabla con los datos, arroja el resultado del conteo de los hogares sin contar los repetidos, pero lo curioso es que el TOTAL al final no suma la realidad de lo que cuenta.

 

Mikaseido1_0-1733792047297.png

Ejemplo valores

 

nombreTerritorionumIdentificacionHogar
T02H1919
T02H1919
T02H1919
T02H1920
T02H0408
T02H0407
T02H0406
T02H0409
T02H0410
T02H0412
T02H0413
T02H0414
T02H0411
T03H1502
T03H1501
T03H1501
T03H1502
T03H1503
T03H1503
T03H1503
T03H1001
T03H1002
T03H1002

 

Conteo esperado

 

nombreTerritorioconteoHogares
T0211
T035
Total16

Requiero de su ayuda en validar como seria la medida para calcular la cantidad de hogares.

 

Gracias.

1 ACCEPTED SOLUTION
v-pnaroju-msft
Community Support
Community Support

Hi @Mikaseido1,

Thank you for reaching out to us through the Microsoft Fabric Community Forum.

 

In addition to the response provided by @Omid_Motamedise  and @wini_R , please find below the solution using DAX to accurately count the total number of distinct households across all territories.To achieve this, we can create a measure using the DISTINCTCOUNT function.

The DAX measure is as follows:

CountHouseholdsByTerritory = DISTINCTCOUNT(Sampledata_101220224[NumIdentificationHome])  

Place the Measure in the Table Visual

  • Add the column to the Rows section of your table visual.NameTerritory
  • Add the measure to the Values section.CountHouseholdsByTerritory

This setup will display the distinct count of households for each territory in the respective rows and the total distinct count across all territories in the grand total row.

 

Please refer to the attached screenshot:

 

xy665423_0-1733824785465.png

If you find this post helpful, kindly mark it as the solution to assist other members in locating it easily.

 

Regards,

Pavan.

View solution in original post

6 REPLIES 6
v-pnaroju-msft
Community Support
Community Support

Hi Mikaseido1,

 

We are following up to see if your query has been resolved. Should you have identified a solution, we kindly request you to share it with the community to assist others facing similar issues.

If our response was helpful, please mark it as the accepted solution and provide kudos, as this helps the broader community.

 

Best Regards,

Pavan

v-pnaroju-msft
Community Support
Community Support

Hi Mikaseido1,

 

We wanted to check in regarding your query, as we have not heard back from you. If you have resolved the issue, sharing the solution with the community would be greatly appreciated and could help others encountering similar challenges.

If you found our response useful, kindly mark it as the accepted solution and provide kudos to guide other members.

Best regards,
Pavan

v-pnaroju-msft
Community Support
Community Support

Hi @Mikaseido1,

 

We have not received a response from you regarding the query and were following up to check if you have found a resolution. If you have identified a solution, we kindly request you to share it with the community, as it may be helpful to others facing a similar issue.

 

If you find the response helpful, please mark it as the accepted solution and provide kudos, as this will help other members with similar queries.

 

Best regards,
Pavan

v-pnaroju-msft
Community Support
Community Support

Hi @Mikaseido1,

Thank you for reaching out to us through the Microsoft Fabric Community Forum.

 

In addition to the response provided by @Omid_Motamedise  and @wini_R , please find below the solution using DAX to accurately count the total number of distinct households across all territories.To achieve this, we can create a measure using the DISTINCTCOUNT function.

The DAX measure is as follows:

CountHouseholdsByTerritory = DISTINCTCOUNT(Sampledata_101220224[NumIdentificationHome])  

Place the Measure in the Table Visual

  • Add the column to the Rows section of your table visual.NameTerritory
  • Add the measure to the Values section.CountHouseholdsByTerritory

This setup will display the distinct count of households for each territory in the respective rows and the total distinct count across all territories in the grand total row.

 

Please refer to the attached screenshot:

 

xy665423_0-1733824785465.png

If you find this post helpful, kindly mark it as the solution to assist other members in locating it easily.

 

Regards,

Pavan.

wini_R
Solution Supplier
Solution Supplier

Hi @Mikaseido1,

 

It looks like you need a solution in DAX but posted your question in Power Query forum 🙂

If your table is as simple as in your example above the following formula should work fine:

Count = COUNTROWS(DISTINCT(tbl[numIdentificacionHogar]))

wini_R_0-1733818544093.png

 

 But if the numIdentificacionHogar column contains same values for different nombreTerritorio, then the formula above might return the unexpected total - it won't be a sum of all rows.  If you want it to be a total of all rows, then please try the following formula:

Count2 = 
SUMX(
    ADDCOLUMNS(
        SUMMARIZE(tbl, tbl[nombreTerritorio], tbl[numIdentificacionHogar]),
        "@count", CALCULATE(DISTINCTCOUNT(tbl[numIdentificacionHogar]))
    ),
    [@count]
)

wini_R_1-1733818742314.png

 

Omid_Motamedise
Super User
Super User

Do you want to do it by power query or Dax?
in power query just right click on the first column, select Group By and then in the opend window pick count row as operator

in the dsax just use CountRows fonctuin and use the table name is its input

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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