Forum Discussion
Table filtered by slicer
Hi
I wonder whether anyone could enlighten me on this - to get a filtered table based on slicer value. Say I have two tables:
States
State_ID State_Name
LG (for Local goverments in the states)
LG_ID LG_Name State_Name
The two tables have a relation linked by Stata_Name in both tables.
Table States has a slicer to allow users to select a state name. I then want to have a table SelectedLG with local government names in the selected state. It's appareanly a very easy job but somehow I can't implment it. Here was how I did in New Table with DAX :
SelectedLG=
VAR SelectedState = SELECTEDVALUE(States, States[State_Name])
Return
CALCULATETABLE(LG, LG[State_Name] = SelectedState)
It resulted in a empty table regardless which state I selected. However SELECTEDVALUE(States, States[State_Name]) does give the correct state name in a table visual, and I got a correct SelectedLG table if I replace the SELECTEDVALUE with the text of a state's name.
Thanks
Charlie
Thank you. I get it. Actually my problem is bit more complex than this - the states and LGs are not a one to many realatioship. The LG is a kind of local geography that are poorly aligned with the states boundaries, that is, one LG may possibly cross 2 to 3 states. The problem I'm faced with is to apply the concordance data (i.e. proportions of a LG assigned to different containing states if it's not fully contained by one signle state) to LGs once a state is selected. I'll repost my problem as a new post. For this consider case closed. Thank you.
Charlie
5 Replies
- venalMemorable Member
Can you please share the sample data and let us know the common column from the 2 tables to re-pro the issue from our end.
If possible please share the expected result.
- charlie77Helper II
Thanks for responding but I realised why it's not working having searched the community - a calculated table is static and will not respond to the slicer on the fly. I'll need to find another approach to my task.
- MFelixSuper UserHi charlie77,
You cannot create a new table using the value selected on slicer.
On this case if you place the slicer and on other visual place the LG names they will be filtered directly no need to create a new table.
Take attention that this is assuming a one to many relationship with single side filtering and you must use the one side tabke as your slicer.
Regards,
MFelix- charlie77Helper II
Thank you. I get it. Actually my problem is bit more complex than this - the states and LGs are not a one to many realatioship. The LG is a kind of local geography that are poorly aligned with the states boundaries, that is, one LG may possibly cross 2 to 3 states. The problem I'm faced with is to apply the concordance data (i.e. proportions of a LG assigned to different containing states if it's not fully contained by one signle state) to LGs once a state is selected. I'll repost my problem as a new post. For this consider case closed. Thank you.
Charlie
- v-eachen-msftCommunity Support