Forum Discussion

Pradgouda18's avatar
Pradgouda18
Regular Visitor
2 years ago

Field Parameter to select Columns for analysis

Hi,

 

I am very new to PowerBI. 

 

I have data in multiple columns (say last 5 year financial data, budgets etc). I need to choose two columns from this and perform analysis (expenses, revenue, profitability by region, by month) etc, variance analysis (difference between these columns). 

 

Can I create a field parameter to choose the two columns and perform analysis somehow? Power Query doesn't seem to recognize the parameter name if i use it in the place of column name.

 

Other option I can think of is create a new table which has these two columns based on the selections made in the Parameter and then work on the analysis. But not sure how to do it.

 

Any help will be appreciated. Thanks

 

 

2 Replies

  • dufoq3's avatar
    dufoq3
    Community Champion

    Hi Pradgouda18, there are many ways. You can select columns by "parameter" like this for example:

     

    Write columns here:

     

    Whole sample code.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTICYmMgNlGK1QGKgIXAYmBBmChEGCIOkQDKxAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
        ColumnsParameter = "Column2, Column4",
        SelectedColumns = List.Transform(Text.Split(ColumnsParameter, ","), Text.Trim),
        TableWithSelectedColumns = Table.SelectColumns(Source, SelectedColumns)
    in
        TableWithSelectedColumns

     

    • Pradgouda18's avatar
      Pradgouda18
      Regular Visitor

      Thanks but I am not sure how to use this. I will post my requirements in a separate query