Forum Discussion
ck18
7 years agoFrequent Visitor
Assistance with SQL Parameters in Power BI - Help with creating a list from SQL Query
So I have been trying to follow this link to create a list in Power BI. For a little background, I am attempting to create a dataset within Power BI that has products, their list price, quantities so...
- 7 years ago
v-cherch-msft, The following worked for me. I was getting my tables and schema mixed up. Also, I needed to use the "each" function to populate the column.
let Source = Sql.Database("localhost", "AdventureWorks2014"), Production_ProductCategory = Source{[Schema="Production",Item="ProductCategory"]}[Data], #"Added Custom" = Table.AddColumn(Production_ProductCategory, "CategoryName", each ProductCategory.Name), CategoriesList = #"Added Custom"[Name], #"RemovedDuplicates" = List.Distinct(CategoriesList) in RemovedDuplicates
v-cherch-msft
7 years agoMicrosoft Employee
Hi ck18
Here is the document for you:
https://www.excelguru.ca/blog/2016/04/28/pass-parameters-to-sql-queries/
Regards,
Cherie
- ck187 years agoFrequent Visitorv-cherch-msft thank you. I finally figured out how to create the list but this documents seems to have other useful information as well.
- v-cherch-msft7 years agoMicrosoft Employee
Hi ck18
Would you share your solution and mark it as solution? That way, other community members will easily find the solution when they get same issue.
Regards,
Cherie
- ck187 years agoFrequent Visitor
v-cherch-msft, The following worked for me. I was getting my tables and schema mixed up. Also, I needed to use the "each" function to populate the column.
let Source = Sql.Database("localhost", "AdventureWorks2014"), Production_ProductCategory = Source{[Schema="Production",Item="ProductCategory"]}[Data], #"Added Custom" = Table.AddColumn(Production_ProductCategory, "CategoryName", each ProductCategory.Name), CategoriesList = #"Added Custom"[Name], #"RemovedDuplicates" = List.Distinct(CategoriesList) in RemovedDuplicates