Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Passing paramater on to List.Range function

Hello everybody,

 

I am currently trying to feed the List.Range function with parameters via a custom function, which sadly does not seem to be working.

 

The custom functions extract a value from the following spreadsheet table:

Ashampoo_Snap_Saturday, March 21, 2020_14h53m07s_002_.png

 

The custom function looks like this:

(ParameterName as text) =>
 let
     ParamSource = Excel.CurrentWorkbook(){[Name="tblParameter"]}[Content],
     ParamRow = Table.SelectRows(ParamSource, each ([Parameter]=ParameterName)),
     Value=
	if Table.IsEmpty(ParamRow)=true
	then null
	else Record.Field(ParamRow{0},"Value")
in
    Value

 

The custom function returns the correct result:

Ashampoo_Snap_Saturday, March 21, 2020_14h57m22s_003_.png

 

Yet when I insert the value returned by the custom function into the following formula, things go south:

 

= Table.SelectColumns(Source,List.Range(Table.ColumnNames(Source),0,14))

 

= Table.SelectColumns(Source,List.Range(Table.ColumnNames(Source),0,fnGetColumn("Submitted Forms: to Column")))

 

I am getting this error:

 

Ashampoo_Snap_Saturday, March 21, 2020_15h00m45s_004_.png

 

If I were to use a Power Query parameter, though, the List.Range function would accept it. But I need to extract the value from the spreadsheet.

 

Hope someone can help me out here!

 

Best regards!

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous,

Could you please check the data source settings in the File-Options-Datasorce settings? I think your datasource for the main query and the workbook has different or none privacy settings. Set them both to same.

Kind regards,
JB
Anonymous
Not applicable

 

This is what my Power Query privacy settings look like:

Ashampoo_Snap_Sunday, March 22, 2020_01h54m32s_001_.png

 

Where are the other privacy settings I am supposed to compare this with?

Anonymous
Not applicable

This is your Excel file - change it to say Organisational. There has to be the same settings for your main datasource - unless sourced from the same file (?). Change it to Organisational too.

Kind regards,
JB
Anonymous
Not applicable

Where do I see the settings for the main datasource? Btw, the main source is a Files from Folder query.

Anonymous
Not applicable

Hi @Anonymous 

 

Can this be the reference to a data files folder one line above the Excel workbook? Otherwise, you may be able to find it in the Global list (switch at the top of the Dialog window).

 

Kind regards,

JB

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors