Forum Discussion
Clients in a certain program
- 9 days ago
Hi JCortez,
You can use below dax
Program3_Only = VAR CurrentClient = Client_program[ClientID] VAR HasProgram3 = CALCULATE( COUNTROWS(Client_program), FILTER( ALL(Client_program), Client_program[ClientID] = CurrentClient && RELATED(Program_Level[prle_listname]) = "Program3" ) ) VAR HasOtherPrograms = CALCULATE( COUNTROWS(Client_program), FILTER( ALL(Client_program), Client_program[ClientID] = CurrentClient && RELATED(Program_Level[prle_listname]) <> "Program3" ) ) RETURN IF(HasProgram3 > 0 && HasOtherPrograms = 0, 1, 0)If you want to check it with date range, use below DAX to create a measure
Program3_Only_In_Range = VAR RangeStart = MIN('Date'[Date]) VAR RangeEnd = MAX('Date'[Date]) VAR CurrentClient = SELECTEDVALUE(Client[ClientID]) VAR HasProgram3InRange = CALCULATE( COUNTROWS(Client_program), REMOVEFILTERS('Date'), FILTER( ALL(Client_program), Client_program[ClientID] = CurrentClient && RELATED(Program_Level[prle_listname]) = "Program3" && Client_program[start_date] <= RangeEnd && ( ISBLANK(Client_program[end_date]) || Client_program[end_date] >= RangeStart ) ) ) VAR HasOtherPrograms = CALCULATE( COUNTROWS(Client_program), REMOVEFILTERS('Date'), FILTER( ALL(Client_program), Client_program[ClientID] = CurrentClient && RELATED(Program_Level[prle_listname]) <> "Program3" ) ) RETURN IF(HasProgram3InRange > 0 && HasOtherPrograms = 0, 1, 0)🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUserand Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!
You can create a calculated table in Power BI that returns clients enrolled in Program3 only, excluding anyone who has ever enrolled in another program.
Assuming Client_program links clients to programs, try:
Program3_Only =
FILTER (
ADDCOLUMNS (
SUMMARIZE (
FILTER (
Client_program,
RELATED ( Program_Level[prle_listname] ) = "Program3"
),
Client_program[Client_ID],
Client_program[start_date],
Client_program[end_date]
),
"Client Name", RELATED ( Client[listname] ),
"Program Name", "Program3"
),
CALCULATE (
COUNTROWS ( Client_program ),
ALLEXCEPT ( Client_program, Client_program[Client_ID] ),
Client_program[Program_ID] <>
LOOKUPVALUE (
Program_Level[Program_ID],
Program_Level[prle_listname], "Program3"
)
) = 0
)
Note: Replace Client_ID and Program_ID with your actual key column names. This assumes relationships are configured correctly between the three tables.
If you share the key columns in Client_program that link to Client and Program_Level, I can provide the exact DAX for your model