cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
newbiepowerbi
Helper II
Helper II

countrows if fact table contains specific value

Hello need refresher in coming up with this simple countrow measure. 

 

Table 1  Table 2 
Site ID  Site IDCategory
A  ABuilding
B  APassive
C  BPassive
D  DBuilding

 

I need to countrows table1 re how many sites that have only passive category in table 2. In the example above, i should get 1 site which Site ID B. appreciate if you can help me on this

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @newbiepowerbi 

Try this measure

Measure_ =
VAR auxT_ =
    CALCULATETABLE ( DISTINCT ( Table2[SiteID] ), Table2[Category] = "Passive" )
RETURN
    COUNTROWS (
        FILTER ( auxT_, CALCULATE ( DISTINCTCOUNT ( Table2[Category] ) ) = 1 )
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

3 REPLIES 3
AlB
Super User
Super User

Hi @newbiepowerbi 

Try this measure

Measure_ =
VAR auxT_ =
    CALCULATETABLE ( DISTINCT ( Table2[SiteID] ), Table2[Category] = "Passive" )
RETURN
    COUNTROWS (
        FILTER ( auxT_, CALCULATE ( DISTINCTCOUNT ( Table2[Category] ) ) = 1 )
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Thank you this is great just to confirm my understanding of the code. you first created a variable table just to identify which sites have "passive" category. then you iterate with said variable table using filter, to check which of this sites have 1 distinct category which should be passive. 

 

Exactly. Good summary

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors