Forum Discussion
Dynamic List Selection in Power BI
- 9 years ago
Here is another method you can use, similar logic to Vvelarde but with physical relationships.
It's based on Anonymous's post here: Tiny Lizard - Dynamically changing chart axis
- Set up tables like this:
SalesStores
Store Filter Type
Sample DAX:
Store Filter Type = VAR FranchiseeTable = SELECTCOLUMNS ( Stores, "Store Name", Stores[Store Name], "Type", "Franchisee Name", "Value", Stores[Franchisee Name] ) VAR DistrictTable = SELECTCOLUMNS ( Stores, "Store Name", Stores[Store Name], "Type", "District Name", "Value", Stores[District Name] ) VAR StoreTable = SELECTCOLUMNS ( Stores, "Store Name", Stores[Store Name], "Type", "Store Name", "Value", Stores[Store Name] ) RETURN UNION ( FranchiseeTable, DistrictTable, StoreTable ) Create relationships as follows (bidirectional between Stores & Store Filter Type):
Then you can simply filter on 'Store Filter Type'[Type], with 'Store Filter Type'[Value] on the visual's axis, with a SUM ( Sales[Sales] ) measure. You still have the ability to filter on Stores if you want, or you could eliminate Franchisee/District columns from Stores.
Regards,
Owen
- Set up tables like this:
Hi there,
Happy to help. To my knowledge there isn't a way to do that with a slicer, since they require a single column to use as the filter selections. Probably not the answer you're wanting to hear or looking for sadly. I've yet to come across any clever workaround that can accomplish this, but if another expert user hops on here with one that would be a great feature to have.
Reid Havens - Principal Consultant
Hi, I found a way to solve it
Steps:
1. Create a New Table:
Table =
UNION (
ADDCOLUMNS ( VALUES ( Table1[Franchise Name] ), "Type", "Franchise" ),
ADDCOLUMNS ( VALUES ( Table1[District Name] ), "Type", "District" ),
ADDCOLUMNS ( VALUES ( Table1[Store Name] ), "Type", "Store" )
)Change the Name of the Column to Options.
2. Create a Measure
SalesM =
SWITCH (
VALUES ( 'Table'[Type] ),
"District", CALCULATE (
SUM ( Table1[Sales] ),
INTERSECT ( VALUES ( Table1[District Name] ), VALUES ( 'Table'[Options] ) )
),
"Franchise", CALCULATE (
SUM ( Table1[Sales] ),
INTERSECT ( VALUES ( Table1[Franchise Name] ), VALUES ( 'Table'[Options] ) )
),
"Store", CALCULATE (
SUM ( Table1[Sales] ),
INTERSECT ( VALUES ( Table1[Store Name] ), VALUES ( 'Table'[Options] ) )
)
)3. Now insert your visuals and Ready (Only test it for your scenario)
- Reid_Havens9 years agoMost Valuable Professional
Vvelarde that's actually a very great solution. I was noodling on a vew ways to do it with joins but didn't want to post anything overly complicated. However you presented a very good solution. Double kudos if I could.
- OwenAuger9 years agoSuper User
Here is another method you can use, similar logic to Vvelarde but with physical relationships.
It's based on Anonymous's post here: Tiny Lizard - Dynamically changing chart axis
- Set up tables like this:
SalesStores
Store Filter Type
Sample DAX:
Store Filter Type = VAR FranchiseeTable = SELECTCOLUMNS ( Stores, "Store Name", Stores[Store Name], "Type", "Franchisee Name", "Value", Stores[Franchisee Name] ) VAR DistrictTable = SELECTCOLUMNS ( Stores, "Store Name", Stores[Store Name], "Type", "District Name", "Value", Stores[District Name] ) VAR StoreTable = SELECTCOLUMNS ( Stores, "Store Name", Stores[Store Name], "Type", "Store Name", "Value", Stores[Store Name] ) RETURN UNION ( FranchiseeTable, DistrictTable, StoreTable ) Create relationships as follows (bidirectional between Stores & Store Filter Type):
Then you can simply filter on 'Store Filter Type'[Type], with 'Store Filter Type'[Value] on the visual's axis, with a SUM ( Sales[Sales] ) measure. You still have the ability to filter on Stores if you want, or you could eliminate Franchisee/District columns from Stores.
Regards,
Owen
- Set up tables like this:
- Humpjs9 years agoAdvocate I
Many thanks to both Vvelarde and OwenAuger. Went with Owen's solution because my real world application of this has much more than just Sales and it was easier to set up for me. Once I'm a little more proficient, I can use Vvelarde's method.
I've learned more from this forum in 2 weeks than I have from any "training".