Forum Discussion
Slicing Calculated Column Sums Using Nested Relation
I'm making a report for displaying equipment parts. Part of that is displaying the count of the parts per piece of equipment and the total cost of replacement associated with them. I have a table with the equipment names (there are duplicate names because they're associated with child data), a table that has each parts associated with their parent equipment, and a parts table that has distinct values. It looks like this:
| Machines Table | Machine- | Part Table | Part | Data Table | ||
| Machine | Machine | Part | Part | Quantity (Calculated Column) | ||
| 1 | 1 | CA | CA | |||
| 2 | 1 | CA | CB | |||
| 3 | 1 | CB | CC | |||
| 4 | Relation | 1 | CB | Relation | CD | |
| 5 | Many:Many | 1 | CB | Many:One | CE | |
| 6 | 2 | CC | CF | |||
| 7 | 2 | CC | CG | |||
| 8 | 2 | CC | CH | |||
| 9 | 2 | CD | CI | |||
| 10 | 2 | CD | CJ | |||
| 11 | 3 | CA | CK | |||
| 12 | 3 | CA | CL | |||
| 13 | 3 | CB | CM | |||
| 14 | 3 | CB | CN | |||
| 15 | 3 | CB | CO | |||
| … | … | … |
I have a table visual that shows the part data and a slicer that filters it using "Machine" from the Machines Table. Some machines share parts with other machines. For the quantity column, I take the count of that part from the second table, filtered by the Machine Name selected in a slicer. However, it doesn't count based on the Machine name; if I select Machine 1, which is identical to Machine 3, it returns the sum of parts for both, whether either or both are selected. It does filter the table to only show the parts inside that Machine (so something's working). The quantities need help though. However, I can't add a condition to the filter for the COUNT where Machines Table[Machine] = Machine-PartTable[Machine] (probably because they're already related).
I've tried ALLSELECTED and USERELATIONSIP but they both return the same incorrect behavior. Here's what I have:
I do apologize if this has already been answered, I couldn't find a similar enough topic. Thanks in advance for any advice/wisdom.
8 Replies
- AnonymousNot applicable
- AnonymousNot applicable
Somewhat, yes. However, in the table, I'm trying to achieve:
1. Each part associated with a machine to be present
2. The quantity of that part in the selected machine
So I'm only doing this with a single slicer based on the Machine Name. The problem I'm having is that my slicer doesn't seem to be filtering down to the Part table, only the MachineToPart table. I changed your file to illustrate and attached it with a drive link - I ungrouped rows in MachineToPart, changed your measure to use COUNT(), and deleted the Part slicer. Somehow, these changes have got it working as I desired, but I have no clue why. It's against everything I've found to be consistent in PowerBI so far (and I wouldn't mind an explanation).
- AnonymousNot applicableHi there.
Well, you have changed only the MachineToPart table but the change is completely inessential from the point of view of functionality. What you've done is you've only expanded the table making it bigger. But the size will be felt only when the table has millions of rows.
I don't understand why you should expand the table since the compact one returns exactly the same results.
Your COUNT( MachineToPart[Part] ) is achievable through COUNTROWS( MachineToPart ).
I don't understand what's really different from the solution I originally posted. I can't see any difference.
The selection of a machine name from the dimension does not filter to the Part dimension because for this to be the case you'd need to change the connection between MachineToPart and Part to be two-way. But two-way cross-filtering is dangerous and should not be used unless strictly necessary.
Best
D