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, 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)
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 ago
Super 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: