Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi, there. We’re a non-profit with 10 community programs. Each person (IND_ID) may join any program once per year, so every fact table is IND_ID × Year.
Goal – count unique individuals while letting users slice by
• program-specific fields (e.g., MomsMeet[Location], SummerYouthGroups[Session])
• shared fields (Year, etc.)
See mockup:
Desired slicer behavior
No slicers selected → show the total distinct individuals count across all 10 programs.
Any slicer selected → return only the individuals that satisfy every chosen slicer (intersection).
Important: Also exclude programs that don’t have a slicer applied.
Current model
Dim Individuals (1) → 10 program fact tables (many).
Why the usual “combine facts into one unioned table” approach fails:
Since each program has fields unique to that program. When you slice on that field, it excludes the rows of the other programs. Making those excluded rows not available for further filtering. And the slicers go blank. See image:
Already tried / ruled out
Looking for: a modelling pattern that keeps other programs and slicers active
Onedrive .pbix is here, I'm glad to check suggestions and report back.
Thanks for any pointers!
---
Moderator note: This is a fully-rewritten, clearer version of my original post (https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-distinct-families-across-multi...); please merge or close the earlier thread if appropriate.
Hi @YSI ,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Thanks @v-nmadadi-msft the issue is still open
So far none the proposals retained all the filter context programs and years, to be available for further filtering.
If anyone has something, I'd be glad to hear.
I'll leave it open in case someone has another idea. Many thanks to all those that gave valuable input so far!
@YSI , I may have missed this if you mentioned, or if someone asked. What is your data source? If it is SQL Server, then the closer you do the manipulations and unions/joins, to the source, the better.
Hey @howellchrisj
Enviromnent: SQL Server and can stage as close to that as possible 😀
What still blocks us -a relationship pattern (not dax, that was hard to scale to 10 programs) that can:
Step 1. Filter by shared program slicers such as Program_name to choose which programs yes to see. (OR logic)
Step 2. Further filter using each program’s unique slicers (Location, Session, …) to exclude in each program (intersection of all slicers) which IND_IDs not to see. (AND logic)
The blocker with making a bridge table (your earlier suggestion) was in step 2: that when the user chooses a program unique slicer like Location, it wipes out the other program rows, making them not available for further filtering. Putting an image, this remains the issue still.
If you have any input, that may solve this fundamental issue.
Thanks again for your help!
This looks accurate per your example of what data should show.
I would be interested to see the full data model, I suspect you need more dimension tables and in the visuals, you can select the option to show records with no data potentially. But this sometimes defeats the purpose of having the dimensions.
Hi @howellchrisj,
Happy to share! The example actually comes from a synthetic PBIX (no real life data, columns or slicer values) due to privacy concerns. In any case, the file using your bridge table idea is here, and original file here
If you need to inspect anything else, let me know and I’ll be glad to take a 60-second screen recording displaying why the rows and slicers blank out.
Thanks again for looking at this.
One approach that you could explore is to add an Active column to each of your fact tables and append a list of all individuals to each fact table.
In Power Query, add a column to each fact table called Active, set it to true and set the type to true / false, e.g.
#"Added Custom" = Table.AddColumn(#"Changed Type", "Active", each true, type logical),
Create a separate query in Power Query which gets the distinct IDs from your individual table and adds a column called Active, set to false, e.g.
let
Source = List.Distinct( Person[Key]),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Key"}}),
#"Added Custom" = Table.AddColumn(#"Renamed Columns", "Active", each false, type logical),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Key", Int64.Type}})
in
#"Changed Type"
You would need to adapt any existing measures to include a filter for 'Fact Table'[Active] = true.
You can now create a measure to count all the matching individuals like
Matching individuals =
CALCULATE (
COUNTROWS ( Person ),
FILTER (
'Fact Table 1',
(
ISFILTERED ( 'Fact Table 1' )
&& 'Fact Table 1'[Active] = TRUE ()
)
|| (
NOT ISFILTERED ( 'Fact Table 1' )
&& 'Fact Table 1'[Active] = FALSE ()
)
),
FILTER (
'Fact Table 2',
(
ISFILTERED ( 'Fact Table 2' )
&& 'Fact Table 2'[Active] = TRUE ()
)
|| (
NOT ISFILTERED ( 'Fact Table 2' )
&& 'Fact Table 2'[Active] = FALSE ()
)
)
)
This uses the expanded fact tables to filter the person table. For each fact table, if that table is filtered then it will only return the active rows which meet the existing filter criteria, if the table is not filtered then it will return every individual, and so will act as if that table was not included in the calculations.
Hi @YSI are you looking for this, have tried it so far, this works well
Hey @techies appreciate the input and work you put in this
Would you mind sharing your model and dax, or the .pbix file? I'd be interested in inspecting!
Hi @YSI here is what i come up, not able to add pbix file
create a bridge table using UNION to consolidate multiple fact tables like this
@techies thanks! I recreated the Bridge table exactly as you outlined and can confirm that step 1 works: You can choose MomsMeet and SummerYouthGroups and get the numbers in either program.
Where it still falls over is the second step: using slicers unique to each program to further filter this count with an intersection of both slicers.
Scenario:
Expected: 1 Individual (IND_ID 138272 appears in both)
Actual:
I suspect it's because the Location column is BLANK() on the SummerYouthGroup rows and Session is BLANK() on the MomsMeet rows, so each slicer wipes out the other program.
Questions
Thanks a lot
Hi @YSI
Yes, you're right about slicers clearing each other out due to BLANKs in the bridge.
pls check this measure that respects each fact table’s native filters and returns the intersection of individuals:
@techies, very interesting thanks again
Your MM & SYG measure does work for two programs, but we’ll soon have 10 program fact tables. The DAX would grow pretty lengthy and challenging to maintain, and there will be more measures needed in the future.
What I’m hoping for
A relationship pattern that keeps all slicers populated and lets a simple measure to:
Step 1. Filter by selected Program + Year (shared slicers)
Step 2. Further filter (by intersection) of each program’s unique slicers (Location, Session, …)
Thank you for your help getting this done!
From the information provided I do not see any reason to combine fact tables. Just have your measures combine the data as needed. Have you tried this appraoch and if so, where there any issues you ran into?
@sjoerdvn, thanks for the idea
Are you suggesting to avoid relationships and instead work the logic with dax alone?
We actually did attempt this and it made each measure to cumbersome to maintain, as there are so many tables and columns.
What do you think?
I am certainly not suggesting to avoid relationships, just to use a straight forward model with multiple fact tables and shared dimension. As always with multiple fac tables the relationships must be single direction though.
Yes, there are many fact tables making measures more verbose, but I do not see how the number of columns complicates things.
Since you've uploaded tables & data, maybe add some expected outcomes based on that data.
👍 so it should just be each fact table linked to each dimension? How do you envision the relationships, as apparently I had trouble getting that part. Can I trouble you to outline all the relationships?
Thanks!
just make sure to set all relations to many-to-one, single direction, even if it defaults differently when creating.
added measure
also tried simple measure, but results are slighly different (overlap between programs)
I need to make a correction here, as it turns out I misunderstood what you were trying to achieve here; so please ignore my previous comments.
So, rethinking this, my solution would be to build one entirly new fact table, with "grain" or primary key on YEAR and IND_ID, so if an individual joins two programs in any given year there would still be one row representing this in the fact table.
I would preferable build this fact table in the source, but power query would also do the trick.
Hey @sjoerdvn, thanks for the work. Challenge we have is (as posed in original question)
The requirement was to have users:
With your approach of making a single table of IND_ID x Year. When slicing by a column unique to just one program, it wipes out the other program rows, making those rows not available for further filtering:
Which model relationship pattern can accomplish this?
The goal is to have a simple measure that allows both shared slicers (Program_name, Year) and unique slicers (Location, Session). Without wiping out filter context of other programs.
That can easily scale to 10 programs and their columns.
Appreciate any direction you may have!
User | Count |
---|---|
16 | |
14 | |
13 | |
12 | |
11 |
User | Count |
---|---|
19 | |
16 | |
15 | |
11 | |
9 |