Forum Discussion
rjstreet
9 years agoFrequent Visitor
Dynamic Column Based on Slicer Selection
I have a situation where users want the ability to have a column change the data presented based on a slicer selection. The analogy would be: Table A: Sales (which is linked to buyer and seller) ...
- 9 years ago
Hi rjstreet
A couple of ideas that you can experiment with:
(PBIX file demonstrating these uploaded here)
- My preferred option:
- Combine Tables B (Buyer) & C (Seller) into a single BuyerSeller table, with an additional "Type" column specifying whether each row is a Buyer or a Seller.
- Then you can use a slicer on Type to choose between Buyer/Seller.
- No 'tricky' DAX is required.
- Similar to your idea:
- Keep Tables B (Buyer) & C (Seller) separate.
- Make the relationship with Table B active, but the relationship with Table C inactive.
- Create a disconnected table to choose between Buyer and Seller, with a corresponding measure to harvest the selected value.
- Set up your Sales measures so that if Buyer is selected, calculation is performed as usual, but if Seller is selected, the relationship with Table B is cleared and the relationship with Table C is activated (using USERELATIONSHIP).
- With this method, you have to explicitly filter out (blanks) from any filters on Tables B & C, so that when Buyer is selected, all Sellers disappear and vice versa.
- You will end up with measures that look like:
Sales Amount = SWITCH ( [BuyerSeller Selected], "Buyer", SUM ( Model2_Sales[Sales] ), "Seller", CALCULATE ( SUM ( Model2_Sales[Sales] ), ALL ( Model2_Buyer ), USERELATIONSHIP ( Model2_Sales[BuyerSeller], Model2_Seller[Seller] ) ) )
Anyway, these are just ideas - see if they are of any use.
Owen :)
- My preferred option:
tschris
3 years agoRegular Visitor
I had to solve this problem myself with a list of 42 columns where I needed to have a single page to plot the sales per day, the items sold per day, the complaints per day etc... the comon dimension was the date but the Y azis had to change from column A to columns B etc.
Since it took me a while to make it happen, I desided to post an example with a dummy sales dataset here. I hope it helps anyone that might face the same issue.