Forum Discussion
I have a parameter which decides which column to select from a table. If the parametet value is "A",
I have a parameter which decides which column to select from a table. If the parametet value is "A", "Column1" should e selected and if the parametet value is "B", "Column2" should e selected . Can I do this with Table.SelectColumns in M code?
3 Replies
- v-juanli-msft
Community Support
Hi AJose
What do you mean by "which column to select from a table"?
Does it mean selecting different columns from table to used in a visual or to used in a formula(measure/calculated column)?
Could you show more details?
Best Regards
MaggieCommunity Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AJose
Helper I
Let me explain the the problem in detail. I am loading data from SharePoint List to Power BI and trying to create a Power BI template. I have defined certain parameters in Power BI using 'Manage Parameters' feature. I need to select the columns from the datasource based on the parameter values . I am using Table.SelectColumns (M Query) to select columns. Is there a way that I can use
1. if statement in Table.SelectColumns like if Parameter value = "A" then column1 else column2. or
2. call a custom function in Table.SelectColumns which will retrun the column name based on the parameter value
- v-juanli-msft
Community Support
Hi AJose
It is possible to use parameter to select data from data source.
Passing parameters to queries in Power Query
Best Regards
MaggieCommunity Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.