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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
RichardP
Helper I
Helper I

Metrics based on one-to-many relationships - with slicers

Hi Power BI community,

 

Despite lots of intensive reading and searching, I'm stuck trying to generate two KPIs from some of my data.

 

I have two tables:

 

Users

userIDuserName
111John
222Sarah
333Bill
444Jane
555Alex

 

Visits

userIDMonthNumberOfVisits
111Jan7
111Feb20
111Mar6
222Feb2
333Jan6
333Feb66
444Feb2
444Mar17
444Apr10

 

There's a one-to-many relationship from the userID on the Users table to the userID on the Visits table. Not every user has an entry in the visits table though.

 

The two metrics I'm trying to achieve are how many unique users visited the website with certain visit counts like between 1 and 5 in sum across all months, and how many did not visit the website (ie they are in the User table but not in the Visits table).

 

To complicate it further, I'm trying to make both of those metrics respect a slicer on the Month so that they update for whatever month(s) the report viewer has selected.

 

I've stared at this all day and I'm so confused! 😕

1 ACCEPTED SOLUTION

Hi @RichardP,

 

You are welcome.  Try this calculate field formula

 

=COUNTROWS(FILTER(SUMMARIZE(Users,Users[userID],"ABCD",SUM(Visits[NumberOfVisits])),[ABCD]>=1&&[ABCD]<=6))

The download link for the revised file is the same as shared above.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

 

You may refer to my solution in this file.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

hi @Ashish_Mathur

 

Thank you so much for this, it is brilliant and a huge help.

 

I think there is just one thing not quite as I would like it in the metrics.

 

I'm splitting the metrics into 1-5 visits, 6-10 visits aind 11+ visits.

 

Doing this, I'm finding that if a user has a month with 1 visit and another month with 6 visits then if both months are selected in the slicer the user is counted in both metrics.

 

I think to avoid this I'd like to sum all of their visits for the selected month(s) and then count them.

 

Is there a way to add that into the calculations somewhere?

 

Thank you once again!

Richard

 

Hi @RichardP,

 

You are welcome.  Try this calculate field formula

 

=COUNTROWS(FILTER(SUMMARIZE(Users,Users[userID],"ABCD",SUM(Visits[NumberOfVisits])),[ABCD]>=1&&[ABCD]<=6))

The download link for the revised file is the same as shared above.

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Amazing, thank you so much! 🙂

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.

Top Solution Authors