Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I want to get a new data source, I only want to get the rows that have a matching value to what is in my Materials list (which is a text string). However, i'm not able to access the string of Materials via a variable in the SQL statement.
Anyone know what I'm missing?
Solved! Go to Solution.
@CMN1BL Hi! In this case, you cannot directly use it as a list in a raw SQL query within Power BI. However, you can make it as a step after the source step, like:
let
Source = Sql.Database("YourServerName", "YourDatabaseName", [Query = "SELECT * FROM YourTable"]),
// Use the existing 'Materials' variable
TrimmedMaterials = List.Transform(Text.Split(Materials, ", "), each Text.Trim(Text.Replace(_, "'", ""))), // Convert the string to a list and clean it up
FilteredRows = Table.SelectRows(Source, each List.Contains(TrimmedMaterials, [Material])) // Filter the rows
in
FilteredRows
BBF
@CMN1BL Hi! In this case, you cannot directly use it as a list in a raw SQL query within Power BI. However, you can make it as a step after the source step, like:
let
Source = Sql.Database("YourServerName", "YourDatabaseName", [Query = "SELECT * FROM YourTable"]),
// Use the existing 'Materials' variable
TrimmedMaterials = List.Transform(Text.Split(Materials, ", "), each Text.Trim(Text.Replace(_, "'", ""))), // Convert the string to a list and clean it up
FilteredRows = Table.SelectRows(Source, each List.Contains(TrimmedMaterials, [Material])) // Filter the rows
in
FilteredRows
BBF
Thank you BBF!🙏
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!