Forum Discussion
How to apply a slicer from one table to another table
edhans Hi there - first I really appreciate your great effort to help me out on this issue. I review your reports. The methods these tables created are really helpful. However, it does not resolve my issue. Our situation is to use Stuff of Table1 as the slicer, rather than the ID of the UniqueTable, so that when a Stuff is choosen both tables 1 and 2 will be filtered.
From the screen shot you can see that when the slicer on the most right is choosen as 'a', only table 1 is filtered but not table 2.
Is this kind of application approachable, i.e. one slicer from one of two unrelated tables can filter the other table?
Again, thank you very much!
Why are you using the value from Stuff as the slicer? Why not use the ID from the bridge table?
Look at the filter relationships in my image above. The bridge table filters both of the other tables, so it should be used as the slicer. I guess I am not understanding what you are trying to accomplish. I am trying to use best practices, and that generally means you use fields from your DIM tables, not FACT tables, as slicers, filters, and fields in visuals. FACT tables do not filter anything (or shouldn't) so those fields are of limited use, other than generic reporting as another column in a table, or providing the "many" side of a 1 to many filter relationship.
Maybe share your PBIX with data that is internal to the file (paste tables in the "Enter Data" function vs linking to files/source in Power Query) as I have done so it is all contained and I can take a look at it, and manipulate the M code if necessary.
- Anonymous6 years agoNot applicable
Thank you so much. Yes, we do need to filter by Staff from table 1. In my situation, we cannot use the unique ID to filter both. The reason behind this is that the user does not care of ID, but only the Staff, plus there are many IDs under each Staff. The situation is simple and straight forward, but I stuck here for many days. Do you think this is approachable?
If not, let's go back to my Table A and B. My target is to show the Sum of Amount in Table B under each Type in Table A. We can simply join Table A and Table B as TableAB. But TableAB will have duplicatate records. Taking ID = 2 as an example, it will have 2-30, 2-10, 2-30 and 2-10 in TableAB. When sum, the amount becomes 80, rather than 40. If there are way to get 40 from TableAB?
Again thank you very much.
- edhans6 years ago
Community Champion
Can you provide some good data? This is a modeling issue. The ID in the DIM table is waht is needed, but we can include other columns in that table. As you say, the user doesn't care about the ID. We can use data from your two tables to create a more comprehensive bridge table with more than just one column. Please use the links below to share data, or share an Excel file (or text or whatever) with some good sample data.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum - Anonymous6 years agoNot applicable
Thank you edhans very much for your diligent on following up this issue. I put one report and one Excel file in One Drive. Hopefully you can access it.
The report - https://1drv.ms/u/s!AlntzgQcvbvR2D4dmQDGa_jCakw7?e=thmaCs
The excel tables - https://1drv.ms/x/s!AlntzgQcvbvR2D0cnh_VTTAaN2Qd?e=G2LT3i
From below, you can see Table1 has ERCode, AllocationAmount adn EventFY, Table2 has ERCode and ObligationAmount. The purpose of this report is to show The sum of Obligation Amount in Table2 by a slicer of EventFY in Table1. Note we cannot join Table1 and Table2 by ERCode as it is not Unique, and join will duplicate records, thus make the sum not correct. As the reports shows, if you click the Slicer, only the Visual of Table 1 changes, Table2 does not, as EventFY is coming from Table1.
If we join Table1 and Table2 by ERCode, and have duplicate records created, do we still can get the Sum(ObligationAmount) correct by certain kind of measure or transformation? I tried to create another table based on the joined one, in which Distinct ERCode and ObligationAmount is selelcted. But the visual of this table does not change after the slicer of EventFY is changed. Basically, I am asking you that if 1 slicer for 2 tables will not work anyway, is there any other way to get the sum right?
As I said earlier that the application situation is simple and straight forward, but it is really hard to get it done.
Thanks!
- edhans6 years ago
Community Champion
Try this Anonymous
I still am not 100% sure on your data. There are a number of ER Codes in Table2 not in Table1, so selecting some codes returns a blank in the table 1 visual. We can work through that.
Above is an image of the model.
- I added a date table. That is now the "year" you should be slicing on. Always try to use FACT tables to manage your slicers, and just about any model with a date can benefit from a date table.
- I added the ER Codes table which is a distint list of all ER codes from tables 1 and 2. It can be just table 2 if you want. It could be table 2 as long as it shows up in table 1 as well. This is what I don't know enough about your business and your use case.
- Anonymous6 years agoNot applicable
Thank you very much! I do not know how this simple situation is hard to understand. Table1 has EventFY and ErCode, table2 has ERCode and ObligationAmount. I want to sum Obligation Amount based on a selection of EventFY. The logic is that a set of ERCode will be defined by a selection of EventFY, then we need to selelct all records in Table2 with ERCode falls in the selection. It is just like a two step slicers integrated into one.
The table schemes I provided are already very simple. It should not be hard to understand what I am trying to reach.
- edhans6 years ago
Community Champion
Ok, perhaps I am getting closer to your goal. Download the PBIX again from the link above.
So...
- I added a new measure called Obligations by Year.
- Selected a year in the slicer
- Totaled the obligations by year based on the ER codes in table 1 using them as a filter for table 2 er codes.
The measure is:
Obligations by Year = CALCULATE( SUM(Table2[ObligationAmount]), TREATAS( VALUES(Table1[ERCode]), Table2[ERCode] ) )Is that better or closer?
If not, can you provide a finished result mockup from Excel. SHow me what the answer should be if I select 2020 as the year for the total obligations if what I have provided isn't right, and how you got there.I apologize I'm not getting your meaning. I think there is a bit of a language issue here, and sometimes when Person A describes a calculation to Person B, Person A thinks it is the clearest explanation in the world, but Person B has no context of the question and is unable to completely piece it all together.
So in this case, Person B, or me, is having to take multiple runs at it to narrow down the exact request. 😁 So be patient with me please.
- Anonymous6 years agoNot applicable
edhans Thank you very much for your time on this. Unfortunately, sum over ERCODE is not our situation. I updated the report and excel file. You can get them from (excel) https://1drv.ms/x/s!AlntzgQcvbvR2D0cnh_VTTAaN2Qd?e=Tsa89V and (report) https://1drv.ms/u/s!AlntzgQcvbvR2D4dmQDGa_jCakw7?e=Ly9r4s
The following shows what we want to reach. A slicer (Event FY) is from Allocation table. When 1990 is selected, the Obligations should show 600 and 1300 for A and B, respectively, and 900, 800 when 1991 is selected. The link between these two tables are ERCODE. But we cannot join them together. If join, the sum of Obligation from the join table will not be right.
Hopefully, this description is clear enough to present our situation. Agai, we appreciate your great help on this.
- edhans6 years ago
Community Champion
I apologize Anonymous . You may want to ask someone else. I just spent 15 min trying to rename the tables and fields in my exisiting model to the new worksheet names and field names in your latest data and my model has errors and my measures all blew up. I'd have to start from scratch.
It is really important to be as clear as possible on the initial request, and your last post probably has everything that is necessary for someone to finish it, but I'm kind of burnt out on it with the source data changing as it did, and new fields (where did State come from?) being added.
- Anonymous6 years agoNot applicable
Thanks a lot edhans