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
JulianC8
Frequent Visitor

Getting data from Excel File for a variable in PowerQuery

Hi everyone,

 

I have a PowerBI File with a lot of diffent tables and queries. In one of these queries I would like to declare a variable called myVar, which contains a indefinite number of values separated by a semicolon. Example:

 

myVar = "Test1;Test2;Test3;Test4"

 

This variable is then further used in my query, which is not described in this post.

 

I now have an Excel File containing these values in one Column. Example:

2024-06-05_13-29-19.png

 

Now my PowerQuery Question: How do i get the data of this Excel File into my PowerBI Data Model so that I can use it in a query as variable in the format as shown above?

I played around with parameters and combining data and so on but I did not come closer to a solution.

 

Any ideas?

 

BR

Julian

 

 

2 ACCEPTED SOLUTIONS
jennratten
Super User
Super User

Hello @JulianC8 - you can use the Excel workbook connector (New Source > Excel Workbook) to connect to your Excel file and get you data.  Once you have the data from Excel you can drill down to the values which creates a list.  Then name the list myVar.

 

jennratten_0-1717587835120.png

 

jennratten_1-1717587917843.png

 

View solution in original post

You're welcome!  If your intent is to add a new column with a list of values separated by a semi-colon, you would do it like this....

= Table.AddColumn(PreviousStep, "Custom", each Text.Combine ( myVar, ";" ), type text )

jennratten_0-1717589486925.png

 

View solution in original post

4 REPLIES 4
JulianC8
Frequent Visitor

Even better! Thanks a lot!

jennratten
Super User
Super User

Hello @JulianC8 - you can use the Excel workbook connector (New Source > Excel Workbook) to connect to your Excel file and get you data.  Once you have the data from Excel you can drill down to the values which creates a list.  Then name the list myVar.

 

jennratten_0-1717587835120.png

 

jennratten_1-1717587917843.png

 

Hi @jennratten 

 

Wow, it was really that easy. Thanks a lot!

 

One remark to round up the solution to my initial problem. In my query I now use the myVar and create a new column out if it (see step "AddCol"). After that I added the second line ExtractValues to get a list of values separated by Semicolons, as I wanted to have.

AddCol = Table.AddColumn(Source, "myColName", each myVar),
ExtractValues = Table.TransformColumns(AddCol , {"myColName", each Text.Combine(List.Transform(_, Text.From), ";"), type text}),

 

 

BR

Julian

You're welcome!  If your intent is to add a new column with a list of values separated by a semi-colon, you would do it like this....

= Table.AddColumn(PreviousStep, "Custom", each Text.Combine ( myVar, ";" ), type text )

jennratten_0-1717589486925.png

 

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.