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

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

Reply
dbollini
Helper II
Helper II

Join Two Tables and Get the values

Hello All,

 

       SELECT @TotalTeamMemberCount = Count(DISTINCT tm.EmpId)

       FROM IPME_TeamMembers tm

       INNER JOIN IPME_Teams t on tm.TeamID = t.ID

       INNER JOIN RideOutEvents roe on t.RideoutEventId = roe.RideOutEventID

       WHERE roe.RideOutEventID = @EventId

       AND (@SectionId = 0 OR t.SectionId = @SectionId);

 

I have to convert this SQL query to DAX where empid from tow tables match and join at Rideoutevent ID and Section id is 0

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

Are these three tables have relationships? i.e., from Teams to team members to ride out events, do they have relationships in place?

 

Then try this. (Try first without ALL and try with ALL - one should work. )

 

 

 

TotalTeamMemberCount = 
Calculate( 
 DISTINCTCOUNT( IPME_TeamMembers[EmpId]), 
 FILTER ( ALL('RideOutEvents'), RideOutEvents [RideOutEventID ] = @EventId ),
                     -- Replace with your variable or value
 FILTER ( ALL('IPME_Teams'), IPME_Teams [SectionId] IN { 0, @SectionId)) 
                     -- Replace with your variable or value 
)

 

 

 

View solution in original post

3 REPLIES 3
sevenhills
Super User
Super User

Are these three tables have relationships? i.e., from Teams to team members to ride out events, do they have relationships in place?

 

Then try this. (Try first without ALL and try with ALL - one should work. )

 

 

 

TotalTeamMemberCount = 
Calculate( 
 DISTINCTCOUNT( IPME_TeamMembers[EmpId]), 
 FILTER ( ALL('RideOutEvents'), RideOutEvents [RideOutEventID ] = @EventId ),
                     -- Replace with your variable or value
 FILTER ( ALL('IPME_Teams'), IPME_Teams [SectionId] IN { 0, @SectionId)) 
                     -- Replace with your variable or value 
)

 

 

 

shafiz_p
Super User
Super User

Hi @dbollini  It is better to provide representative data and desired output to get the accurate result. Anyway, you could try the below code to convert SQL to DAX:

TotalTeamMemberCount = 
CALCULATE(
    DISTINCTCOUNT(IPME_TeamMembers[EmpId]),
    FILTER(
        IPME_TeamMembers,
        IPME_TeamMembers[TeamID] IN 
        SELECTCOLUMNS(
            FILTER(
                IPME_Teams,
                IPME_Teams[RideoutEventId] = @EventId &&
                IPME_Teams[SectionId] = @SectionId -- Replace this with the desired ID
            ),
            "TeamID", IPME_Teams[ID]
        )
    )
)

 

Change EventID and SectionID accordingly.

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

dbollini
Helper II
Helper II

users not Checkedin = CALCULATE(DISTINCTCOUNT(IPME_TeamMembers[EmpId]))-CALCULATE(DISTINCTCOUNT(ReportRideOutCheckInsView[Id]))
But this is not giving me correct counts

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.