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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.