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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DeeGee
Frequent Visitor

Summary numbers from many-to-many relationship tables

Hello,
I'm having a challenge with getting a many-to-many relationship to report on summary numbers. Let me set the stage as follows.
 
I have four tables:
  1. Service_requests - A table holding raw data about service requests from our CRM.
  2. Event_clicks - A table holding raw data about click events from our website analytics; the current setup is that web forms have been provisioned to capture service requests which are then stored into our CRM.
  3. Request_types - A 3rd table that is a bridge between Service_requests and Event_clicks; defines a taxonomy of request types and unique categories.
  4. Calendar - Standard date dimension table
 
DATA:
 
Request_types
=============
Type,Category
Animals,Animal Registration
Animals,Dog Park enquiry
Bookings & Events,Venue Booking

Service_requests
================
Date,Request_type,Request_category,Reference,Details
6/03/2019,Bookings & Events,Venue Booking,0268-1235,Diverse coherent parallelism
28/08/2019,Animals,Animal Registration,43857-0096,Team-oriented exuding utilisation
26/05/2019,Animals,Animal Registration,29300-126,Re-contextualized uniform orchestration
5/04/2019,Animals,Animal Registration,50580-779,Ameliorated discrete migration
5/09/2019,Animals,Animal Registration,51346-081,Networked modular encryption
3/05/2019,Animals,Animal Registration,49781-042,Realigned composite access
18/05/2019,Animals,Animal Registration,58593-780,Virtual asynchronous ability
21/10/2019,Animals,Animal Registration,10849-001,Advanced intermediate data-warehouse
4/09/2019,Animals,Animal Registration,62175-261,Reduced fault-tolerant synergy
21/07/2019,Bookings & Events,Venue Booking,35356-790,Phased upward-trending moratorium
14/06/2019,Animals,Animal Registration,52982-105,Monitored clear-thinking matrices
5/06/2019,Animals,Animal Registration,0268-6709,Reverse-engineered real-time forecast
23/08/2019,Animals,Animal Registration,59450-034,Open-architected fresh-thinking structure
10/11/2019,Animals,Animal Registration,63739-475,Cloned modular utilisation

Event_clicks
============
Date,URL,Event_count,Product,Category
2019-03-11,http://dummyimage.com/227x145.jpg/cc0000/ffffff ,5,Animals,Animal Registration
2019-04-22,http://dummyimage.com/151x174.png/ff4444/ffffff ,5,Bookings & Events,Venue Booking
2019-05-03,http://dummyimage.com/105x118.jpg/cc0000/ffffff ,3,Animals,Animal Registration
2019-09-18,http://dummyimage.com/230x213.bmp/cc0000/ffffff ,1,Bookings & Events,Venue Booking
2019-11-19,http://dummyimage.com/115x162.png/dddddd/000000 ,5,Bookings & Events,Venue Booking
2019-08-14,http://dummyimage.com/170x194.jpg/5fa2dd/ffffff ,5,Animals,Animal Registration
2019-02-21,http://dummyimage.com/136x217.jpg/ff4444/ffffff ,2,Bookings & Events,Venue Booking
2019-05-05,http://dummyimage.com/230x245.png/ff4444/ffffff ,2,Bookings & Events,Venue Booking
2019-11-12,http://dummyimage.com/118x175.jpg/5fa2dd/ffffff ,3,Bookings & Events,Venue Booking
2019-12-23,http://dummyimage.com/235x171.png/dddddd/000000 ,4,Animals,Animal Registration
2019-11-26,http://dummyimage.com/230x137.png/cc0000/ffffff ,2,Animals,Dog Park enquiry
2019-11-18,http://dummyimage.com/110x215.png/ff4444/ffffff ,2,Animals,Animal Registration
2019-08-14,http://dummyimage.com/232x119.bmp/5fa2dd/ffffff ,4,Animals,Dog Park enquiry
2019-08-10,http://dummyimage.com/249x230.jpg/cc0000/ffffff ,4,Animals,Animal Registration
2019-06-04,http://dummyimage.com/111x169.jpg/5fa2dd/ffffff ,1,Bookings & Events,Venue Booking
2019-09-19,http://dummyimage.com/197x250.jpg/dddddd/000000 ,2,Bookings & Events,Venue Booking
2019-06-22,http://dummyimage.com/240x179.jpg/cc0000/ffffff ,4,Bookings & Events,Venue Booking
2019-03-27,http://dummyimage.com/102x108.png/cc0000/ffffff ,5,Bookings & Events,Venue Booking
2019-10-11,http://dummyimage.com/234x240.jpg/ff4444/ffffff ,3,Bookings & Events,Venue Booking
2019-11-24,http://dummyimage.com/170x179.jpg/5fa2dd/ffffff ,1,Bookings & Events,Venue Booking
2019-01-19,http://dummyimage.com/248x206.bmp/5fa2dd/ffffff ,5,Animals,Animal Registration
2019-12-15,http://dummyimage.com/221x159.jpg/cc0000/ffffff ,2,Bookings & Events,Venue Booking
2019-04-01,http://dummyimage.com/140x221.bmp/dddddd/000000 ,5,Bookings & Events,Venue Booking
2019-09-04,http://dummyimage.com/164x240.jpg/ff4444/ffffff ,1,Bookings & Events,Venue Booking
2019-01-23,http://dummyimage.com/115x235.jpg/dddddd/000000 ,2,Animals,Animal Registration
2019-08-18,http://dummyimage.com/113x141.png/ff4444/ffffff ,2,Bookings & Events,Venue Booking
2019-12-11,http://dummyimage.com/174x220.bmp/ff4444/ffffff ,1,Animals,Animal Registration
2019-02-22,http://dummyimage.com/123x165.png/ff4444/ffffff ,2,Animals,Dog Park enquiry
2019-09-21,http://dummyimage.com/174x122.bmp/dddddd/000000 ,4,4,Animals,Dog Park enquiry
2019-06-30,http://dummyimage.com/240x153.jpg/5fa2dd/ffffff ,5,Bookings & Events,Venue Booking
2019-08-19,http://dummyimage.com/176x250.png/5fa2dd/ffffff ,4,Animals,Animal Registration
2019-02-12,http://dummyimage.com/237x218.png/cc0000/ffffff ,3,Animals,Animal Registration
2019-06-11,http://dummyimage.com/222x134.png/dddddd/000000 ,1,Animals,Animal Registration

RELATIONSHIPS:
Request_types (Category) 1:* Service_requests (Request_category) - active
Request_types (Type) *:* Event_clicks (Product) - inactive
Request_types (Category) *:* Event_clicks (Category) - inactive
 
I need to produce a visualisation that shows a list of all request types and their unique categories, sum of event clicks and distinct count of service requests.
 
I have solved the puzzle halfway - I did not have qualms coming up with a visualisation for request types, categories and sum of event clicks. The biggest issue I'm having at the moment is including the distinct count of service requests.
 
What I'm expecting are results like:
 
Type:Category:URL_clicks:Service_requests:% of service requests:
AnimalsAnimal Registration391285.70%
AnimalsDog Park Enquiry1200%
Bookings & EventsVenue Booking49214.30%
 
N/B: Explanation of zero (0) count under Service_requests - Sometimes, an event click to a web form might not eventuate to an actual service request in the CRM.
 
Also, using the calendar table in a slicer, the visualisation can be analysed across different time periods.
1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Alright, this is a fun question and a big thank you for adding some dummy data so we can try stuff out in Power BI. The first thing we need to do is to create new relationships. The reason for this is that your dimension table (request_types) has multiple columns that can be linked to, that needs to be one. In you sample we could just choose the unique column (e.g. category) but this might not be a unique column in your real data set. To create a unique column in Request_types, let's add an index table to it in the power query editor:

image.png

Now every row is numbered uniquely. We just have to add calculated columns to the two other tables. The DAX for this is the following for table Event_clicks

 

CategoryIndex = LOOKUPVALUE(Request_Types[Index], Request_Types[Category], Event_clicks[Category], Request_Types[Type], Event_clicks[Product])

 

 And for Service_requests:

 

CategoryIndex = LOOKUPVALUE(Request_Types[Index], Request_Types[Category], Service_requests[Request_category], Request_Types[Type], Service_requests[Request_type])

 

Now we are going to create relationships as follow:

image.png

These are one to many, and now you have a 'normal'  datamodel. Now we are going to create a Table visual with the following columns:

image.png

 Note that the first and second column are from the Request_types table, the third column is from Event_Clicks, the third is a distinct count of Reference column in Service_Request and the measure in the last column has the following DAX:

 

% of Service Requests = DIVIDE(DISTINCTCOUNT(Service_requests[Reference]), CALCULATE(DISTINCTCOUNT(Service_requests[Reference]), ALLSELECTED(Service_requests)))

 

My PBIX can be found here for your convience.

 

Let me know if this answers your question, and if you have any others please let me know 🙂 Kudo's are appreciated.

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
JarroVGIT
Resident Rockstar
Resident Rockstar

Alright, this is a fun question and a big thank you for adding some dummy data so we can try stuff out in Power BI. The first thing we need to do is to create new relationships. The reason for this is that your dimension table (request_types) has multiple columns that can be linked to, that needs to be one. In you sample we could just choose the unique column (e.g. category) but this might not be a unique column in your real data set. To create a unique column in Request_types, let's add an index table to it in the power query editor:

image.png

Now every row is numbered uniquely. We just have to add calculated columns to the two other tables. The DAX for this is the following for table Event_clicks

 

CategoryIndex = LOOKUPVALUE(Request_Types[Index], Request_Types[Category], Event_clicks[Category], Request_Types[Type], Event_clicks[Product])

 

 And for Service_requests:

 

CategoryIndex = LOOKUPVALUE(Request_Types[Index], Request_Types[Category], Service_requests[Request_category], Request_Types[Type], Service_requests[Request_type])

 

Now we are going to create relationships as follow:

image.png

These are one to many, and now you have a 'normal'  datamodel. Now we are going to create a Table visual with the following columns:

image.png

 Note that the first and second column are from the Request_types table, the third column is from Event_Clicks, the third is a distinct count of Reference column in Service_Request and the measure in the last column has the following DAX:

 

% of Service Requests = DIVIDE(DISTINCTCOUNT(Service_requests[Reference]), CALCULATE(DISTINCTCOUNT(Service_requests[Reference]), ALLSELECTED(Service_requests)))

 

My PBIX can be found here for your convience.

 

Let me know if this answers your question, and if you have any others please let me know 🙂 Kudo's are appreciated.

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @JarroVGIT,
 
Thanks for your swift response.
 
Your suggested solution does fit my requirements. However, in my case, I'm unable to get a distinct count of Reference column even after replicating the suggested solution - quite puzzling given that Event_count does a sum as expected so would not expect that the Count (distinct) is 'broken'. This also affects the measure in the last column, as seen in the screenshot below:
 table_viz.png
 
Am I missing something?

That is really hard to say without seeing your pbix, is it possible to share?




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi Djerro123,
 
I had a play around with the pbix - the reason that the count of reference was not showing is due to dynamic filtering based on slicer values from the calendar table.
 
When the value of the slicer is 'All', the count of reference appears for all the rows in the table:
All.png
However, when I select one or more values on the slicer (from the MonthAbbrAndYear column), the count of reference does not show:
Filtered.png
The pbix file is attached!
 
How do I go about resolving the count of reference and % of service requests to also show when one or more values on the slicer are selected?

Hi @DeeGee ,

 

The problem is in the data type of the date column in service requests table. If you go to Power Query Editor you see this is clear text. Because of the relationship with the calendar table, this will always filter to zero rows when a date (range) is selected in the calendar table. 

Because I am on a different locale then you, my dates are written differently. 02/01/2020 means January 2nd in your data set but in my PowerBI (and probably yours as well?) it is February 1st. That means when I convert it to a date column, it will throw a few errors (e.g. 21/07/2019 doesn't excists because there is no 21st month). Fixing the data issue will fix your issue with the filter column 🙂

What I personally learnt from this is that when you select "Select All" in a slicer, it deletes any filters on the column it is slicing, while selecting all options in the dropdown list filters with all possible values. (in your case, selecting Select All removed the filter on the date column, but selecting all months seperately also shows no counts of references). 

Anyway, hope this resolves your issue, let me know if you have any furter questions and don't forget to like posts that helped you and mark any posts as the solution if it answered your question(s) 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.