Forum Discussion
Calculation With Filters
- 1 year ago
Hi Rich_Wyeth,
Thank you for reaching out to Microsoft Fabric Community.
Due to the many-to-many relationships and use of bridge tables like KITS JOIN, the slicer does not automatically filter KITS 2024. This is why you are seeing overall totals instead of values specific to the selected part.
Use this below measure, it will correctly respects the slicer selection and filters the kit quantities accordingly:
M_THECALC =
VAR SelectedParts = VALUES('Margin Report'[PN])
VAR DirectQty =
CALCULATE(
SUM('Margin Report'[QTY]),
KEEPFILTERS(SelectedParts)
)
VAR KitsQty =
CALCULATE(
SUM('KITS 2024'[Quantity]),
TREATAS(SelectedParts, 'KITS 2024'[Part Number])
)
RETURN
DirectQty + KitsQty
And also ensure 'KITS 2024'[Part Number] and 'Margin Report'[PN] have the same data type and check if all the relevant relationships in the model are active.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thanks and regards,
Anjan Kumar Chippa
Is there a relationship between kits and margin?
- Rich_Wyeth1 year agoHelper I
Yes, they are joined by Part Number [PN}
- Deku1 year agoSuper User
What type of relationship? Margin 1:many kits?
- Rich_Wyeth1 year agoHelper I
It is Many to Many.
The Margin Table holds a column for Part Number, some of these part numbers are Kit numbers. So I have a Kits Join Table (Kit Number & Part Number) and a Kit Numbers table (Kit Number & Part Number). The Join table links to the Margin Report via [PN] and the Kits Numbers table links to Kits Join via the Kit Number. This is the only way I have been able to get the sums to work correctly from each table. I now want a total number of the two, which I am struggling to achieve. Joins