The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Good morning/afternoon.
I cannot get my head around this so I cast this to the community.
I have two tables
Table1
Name CM Appointments
Joe Joe2025-01 1
Joe Joe2025-01 1
Joe Joe2025-02 1
Bert Bert2025-01 1
Table2
Name CM DaysLeave
Joe Joe2025-01 3
Joe Joe2025-02 4
I need to get a report from table 1 that sums the appointments for a CM (That bit was easy) and gives me the days leave from table2. Note there will only be a single record in Table2 for any particulare name/CM combination.
The CM COLUMN in both tables is derived from a date and the name of the person and is used to join the tables together.
The report I am after is based on a slicer that (effectivly filters table one to a range of CM's
The report should show (assuming I filter for 2025-01 and 2025-02
Name Appointments Leave
Joe 3 7
Bert 1 0
So I need a way of creating a measure on Table1 that picks up the leave from table2 for all the CM's for the filtered value.
For Joe if I use RELATED leave, the leave days would end up being wrong because the RELATED will bring back the leave for every instance of Joe2025-01 and Joe2025-02
(The actual data would be)
Joe joe2025-01 3
Joe joe2025-01 3
Joe Joe2025-02 4
Which means his total leave days becomes 10 - instead of 7
Fundimentally I really only want to pick up the leave for the first instance of CM - rather than every instance of CM.
I truly hope the above makes sense - I find it very hard to describe but hope I have succeeded
Stan
Solved! Go to Solution.
As mentioned the actual measure is;
OK - got it to now work in a card.
The actual formula is
As mentioned the actual measure is;
Hi @stan_w_gifford ,
Thank you for your response. If you have any question relating to the current thread, please do let us know and we will try out best to help you.
Regards,
Dinesh
Whoops - forgot the measure I am using;
OK - I did a sin that I would normally beat my staff for (if I had any staff) - I left some facts out.
1. Not every line in Table 1 would have appointments for a specific CM
2. I want to put the result into a card!
At the moment I have got a measure working - I I put my data into a matrix, it looks like this (all data from Table1)
What I want to put in the card is a single value - from above the value would be 8 (8 days leave over the period)
If I put the measure into the card I get a nice big fat BLANK!
Hi - still working on this - have been ill for a couple of days - not quite got it - but studying suggested answer.
Stan
Hi @stan_w_gifford ,
As you mentioned in your previous response, You are working on proposed solution suggested by @jaineshp . Please do let us know if you have any further queries.
Regards,
Dinesh
Hey @v-dineshya,
Thank you for the kind recognition - always happy to contribute to our community's success!
Best Regards,
Jainesh Poojara | Power BI Developer
Hi @stan_w_gifford ,
Thank you for reaching out to the Microsoft Community Forum.
Hi @jaineshp , Thanks for your prompt response,
Hi @stan_w_gifford , Could you please try the proposed solution shared by @jaineshp , Please do let us know if you have any further queries.
Regards,
Dinesh
Hey @stan_w_gifford,
Problem Analysis: You're experiencing the classic many-to-one relationship challenge where RELATED() function duplicates values across multiple rows, causing inflated totals in your measures.
Recommended Solution Steps:
Step 1: Create a Summarized Leave Measure Instead of using RELATED(), create a measure that aggregates leave days at the Name level:
Total Leave Days =
SUMX(
VALUES(Table1[Name]),
CALCULATE(SUM(Table2[DaysLeave]))
)
Step 2: Alternative Approach - Distinct Count Method If the above doesn't work perfectly with your slicer setup, try this approach:
Leave Days Measure =
VAR CurrentName = MAX(Table1[Name])
RETURN
CALCULATE(
SUM(Table2[DaysLeave]),
Table2[Name] = CurrentName,
ALL(Table1)
)
Step 3: Verify Relationship Setup
Step 4: Report Structure Create your visual with:
Step 5: Testing Test with your CM slicer filtering for 2025-01 and 2025-02. You should now see:
Key Point: The measure approach prevents the multiplication effect because it aggregates at the Name level first, then applies the filter context from your slicer.
This solution maintains the integrity of your leave calculations while properly handling the many-to-one relationship structure.
Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
Best regards,
Jainesh Poojara / Power BI Developer