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)
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".