Forum Discussion
Fabric Warehouse Incorrect Query Results
I'm hoping to get some guidance from the group on where to go with this. I have 2 queries that run in sequence that read from my Fabric data warehouse. The queries are different and should yield different results but when they run, they actually return the same data.
yeah, best to raise a ticket with product support - use the menu above Support > Product Support to log the new support case. Please make it clear in the ticket that removing the variable StartingDate resolves it; and the issue seems to be happening quite recently.
If my workaround helped please mark it as a solution, so that others in this situation can take advantage of this workaround!
6 Replies
- deborshi_nagSuper User
Hello mheggie
It is a very strange behavious indeed! Can you try using a WITH clause instead of a IN clause and let me know if you see any difference in the behaviour? Here's one of your query with a WITH clause.
-- Derive the starting date: first day of the current year minus 10 years DECLARE @StartingDate DATE = DATEADD(YEAR, -10, DATETRUNC(year, GETDATE())); WITH PayrollGL AS ( SELECT DISTINCT F.ExpenseGLAccountKey FROM gold.FactPayrollHistory AS F JOIN gold.DimDate AS D ON F.PeriodEndDateKey = D.DateKey WHERE D.CalendarDate >= @StartingDate ) SELECT a.* FROM rpt.vw_DimGLAccount AS a JOIN PayrollGL AS p ON a.[GL Account Key] = p.ExpenseGLAccountKey;- mheggieFrequent Visitor
Thanks for your suggestion.
I tested with your query for both expense and liability and they both return what is expected. I had already worked around this by replacing @StartingDate in the where clause with the expression I was using to calculate it and it works.
select * from rpt.vw_DimGLAccountwhere [GL Account Key] in (SELECT F.ExpenseGLAccountKeyFROM gold.FactPayrollHistory FJOIN gold.DimDate D ON F.PeriodEndDateKey = D.DateKeyWHERE D.CalendarDate >= DATEADD(YEAR, -10, DATETRUNC(year, GETDATE())));There are definitely some workarounds for this which is why it feels like a bug to me.The process that uses this has been running successfully in production since May 2025. This issue just appeared in the last few weeks.- deborshi_nagSuper User
yeah, best to raise a ticket with product support - use the menu above Support > Product Support to log the new support case. Please make it clear in the ticket that removing the variable StartingDate resolves it; and the issue seems to be happening quite recently.
If my workaround helped please mark it as a solution, so that others in this situation can take advantage of this workaround!
- v-echaithraCommunity Support
Hi mheggie ,
Thank you for reaching out to Microsoft Community.I recommend reporting the bug using the link below on the MS Fabric Forum.
Issues - Microsoft Fabric Community
Thanks & Regards, - stoic-harshSuper User
Hi mheggie,
Before concluding it an engine bug or caching issue, I would like to first think purely from a data/query perspective. If you are only looking at row counts as validation, it is possible that even if there are only 67 distinct liability keys, [GL Account Key] in rpt.vw_DimGLAccount may contain 2,365 rows matching these 67 keys (given, no DISTINCT is being applied in the outer query).
Another reason could be that [LiabilityGLAccountKey] and [ExpenseGLAccountKey] contain identical values, or one is a subset of other, over the filtered date range.
Could you first verify this, by looking at the actual result sets, rather than relying solely on row counts?
- mheggieFrequent Visitor
Thanks for the feedback. I have evaluated the results along with the counts. What I've shared in my post is accurate. I should get 2365 rows returned for one query and 67 for the other. LiabilityGLAccountKey and ExpenseGLAccountKey values are not identical and are not a subset of one another. Liabilities post to a different place in the GL than expenses.
If I change the "select *" in each query to a "select count(*)", the numbers returned are correct. When I then change the "count(*)" back to "*", it returns the same result for both.
Also ... the process with this logic has been running successfully in production since May 2025. It is only in the last few weeks that this has been a problem. I've tested this with other keys that reference the same dimension and can consistently re-create the issue.
When the second query runs, it notes that it is using cached results.