Search code examples
stringfilterpowerbicomparisondax

PowerBI: Comparing a filterd table against a variable string is returning an empty table


Please see the code below for a Power BI table in DAX:

TABLE1 =

VAR ParticipantOneParticipantId =     
SELECTEDVALUE(
    ParticipantOneDetails[ParticipantId]
)

RETURN 
FILTER(
    ParticipantOneMeetings, 
    ParticipantOneMeetings[ParticipantId] = ParticipantOneParticipantId
)

I am fetching a value for ParticipantId from a sliced table called ParticipantOneDetails and setting ParticipantOneParticipantId to it.

In the next step I am trying to filter the table ParticipantOneMeetings based on its column ParticipantId comparing it against ParticipantOneParticipantId.

The problem is that the resulting table is coming out empty even though I know that ParticipantOneParticipantId must have a value and the ParticipantOneMeetings table also has values. I verified by comparing against a hard-coded string.

Can you please point out what I am doing wrong? Is comparing this way not legal?


Solution

  • Turns out I needed to add the following measure to the table output:

    MeetingsAttendedByBothParticipants = 
    countrows(
        INTERSECT(
            VALUES(ParticipantOneMeetings[Name]), 
            VALUES(ParticipantTwoMeetings[Name])
        )
    )
    

    The above provides an intersection on output of two sliced meeting tables. This results in a list of meetings that both persons attend.