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
I'm having a problem where the primary key of a table I import into Power Query using a SQL statement is not showing up. I have another table where I used a similar select statement and did not have this issue.
My SQL statement is below:
Select * from Pharmavail left join TerritoryContracts on entity = nameOfEntity and TerritoryContracts.newTerritoryID = Pharmavail.territory and (`month` between originalContractDate and endContractDate ||
`month` >= originalContractDate and endContractDate IS NULL);
When I run this query in Workbench the primary key is returned. Additionally, on a similar query below I do not have this problem and the primary key imports without issue.
select * from Pharmavail left join ProductInfo on CONCAT('GD',Pharmavail.NDC)=ProductInfo.NDC WHERE (groupId = 'GALTCSH' or groupId = 'GALTCSH2' or groupId = 'GALTCSH3') and ((`month` between StartDate and EndDate) or (`month` >= StartDate and EndDate IS NULL));
Any insight will be greatly appreciated!
Hi, @alandilworth
Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution and you are welcome to share your solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your .pbix file after removing sensitive data.
Hi, @alandilworth
Do you mean that the primary key column is not returned in PQ?
Can you share the screenshot of the data obtained after returning the query in the data source and in powerbi(hide privacy)?
You can try to click on Refresh button (Refresh all) in PQ to see if this column will appear. Also, you can test instead of using * just to select only the PK column in your SQL query in PBI import
Appreciate your Kudos !!!
Proud to be a Super User!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 132 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |