Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi There,
I wonder if anyone can help me. I'm trying to count the number of unique user ID that fit a certain date range across a number of different entities. I need to use a particular relationship for each entity to correctly link to my calendar table.
I've tried this, but it's not working:
Hi @adamlang ,
Maybe this would help you.Please have a try.
Total Unique People Supported =
COUNTROWS (
DISTINCT (
UNION (
CALCULATE (
COUNTROWS (
DISTINCT ( VALUES ( Appointment[Contact.ccl3030_uniquecrmnumber] ) )
),
USERELATIONSHIP ( Appointment[Appointment Start Date or Scheduled Start Date], Calendar[Date] )
),
CALCULATE (
COUNTROWS ( DISTINCT ( VALUES ( Contact[ccl3030_uniquecrmnumber] ) ) ),
USERELATIONSHIP ( Contact[createdon], Calendar[Date] )
),
CALCULATE (
COUNTROWS (
DISTINCT (
VALUES ( new_connectionzonevisits[Contact.ccl3030_uniquecrmnumber] )
)
),
USERELATIONSHIP ( new_connectionzonevisits[new_timearived], Calendar[Date] )
),
CALCULATE (
COUNTROWS (
DISTINCT ( VALUES ( pre_projectenrolment[Contact.ccl3030_uniquecrmnumber] ) )
),
USERELATIONSHIP ( pre_projectenrolment[pre_enddate], Calendar[Date] )
),
CALCULATE (
COUNTROWS (
DISTINCT ( VALUES ( pre_projectenrolment[Contact.ccl3030_uniquecrmnumber] ) )
),
USERELATIONSHIP ( pre_projectenrolment[pre_startdate], Calendar[Date] )
),
CALCULATE (
COUNTROWS (
DISTINCT ( VALUES ( pre_referral[Contact.ccl3030_uniquecrmnumber] ) )
),
USERELATIONSHIP ( pre_referral[pre_referraldate], Calendar[Date] )
),
CALCULATE (
COUNTROWS (
DISTINCT ( VALUES ( pre_workshopattendance[Contact.ccl3030_uniquecrmnumber] ) )
),
USERELATIONSHIP ( pre_workshopattendance[pre_workshopdate], Calendar[Date] )
)
)
)
)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Rongtie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous Thanks for taking the time to respond, I think this in on the right lines, i.e. nesting each USERELATIONSHIP within its own CALULATE function.
However I think sometime might be wrong with the syntax maybe, I get the following error:
"The UNION function expects a table expression for argument '7', but a string or numeric expression was used."
I tried simplifing the DAX code to just look at two entities which I know need to use the inactive relationships, just to check the syntax, and get started, making sure it wasn't a data model issue somewhere. but that returned a similar error message too.
Would CALCULATETABLE maybe offer a solution if UNION is expecting a table rather than a value? I've not used CALCULATETABLE much, and the videos I just watched confused me.
If it helps I'm able to use individual measures to calulate the unique clients in each entity as below, I just want to be able to count unque clients across all the entities together, i.e. removing any duplicant client numbers.
My current indiviudal measures are:
I think i've made some progress with this using VAR, it seems to be working, although I'm not sure how I would manually test it. Does the following make sense:
Thanks,
Adam
Just to add to this.
A number of columns can just use the active relationship in the data model, and so the following measure works for them.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
9 |