Forum Discussion
Data Model in Service duplicating and replacing rows
- 8 years ago
Hi Ed. As I said over email, we've identified the root cause of this issue. We're currently targeting the fix for our July release.
In the meantime, you can work around the issue by ensuring that your folded queries are always sorted. This can be done by always including (and preserving in downstream queries) all primary keys for a given table. Or, if this isn't possible (as in your case when doing a Group By operation), you can explicitly sort by a set of unique keys before combining. (Also note that it may be necessary to buffer after sorting and before combining to ensure the sort is applied by the folding layer. You'll have to experiment to see whether or not this is necessary.)
Ehren
I ran a test and this is what I am seeing:
- The table that shows the error is a result of a Table.Combine in Power Query.
- I took the two source queries to that and loaded them into the data model.
- I then used a DAX UNION() statement to generate a new table in Power BI.
- I build a new measure in the new DAX table to replicate a mesaure in the table loaded from the Table.Combine query and stuck it on a card.
- Refreshed everything in Power BI Desktop. Both the measure from the orginal table and the measure from the DAX UNION function show the same result.
- Published to my workspace, connected to the Gateway and refreshed.
- The measure in the DAX UNION table works fine.
- The measure in the original table is off by these random rows.
Something isn't right with how the Table.Combine statement is being loaded either by the Gateway or being handled by the service. The desktop app is fine.
Hi Ed. I've tried reproducing this locally (using SQL data refreshed via a Gateway) and am unfortunately not seeing any duplication. Would it be possible for you to try some other things for me?
- Do your SQL queries involve passing native SQL statements (e.g. "select * from myTable"), or do they simply connect to the tables? What transforms (if any) are you doing on top of the SQL data?
- Try duplicating the query that does the Table.Combine operation, and then buffering the result (i.e. add a step at the end that does = Table.Buffer(previousStep)). Does this version of the query exhibit the same behavior?
- Try duplicating the query that does the Table.Combine operation, and buffering each individual table being combined (e.g. = Table.Combine({Table.Buffer(Query1), Table.Buffer(Query2)})). Does this version of the query exhibit the same behavior?
- Try duplicating the query that does the Table.Combine operation and doing a group by and count of the unique field you're seeing duplicated, then filter for Count > 0 (which should return an empty table when run locally in PBIDesktop). When refreshed via the gateway, does this query produce any results?
I'm trying to pinpoint if the issue is happening on the M query side of things or somewhere in the AS pipeline.
Thanks for your help.
Ehren
- Ehren8 years agoMicrosoft Employee
Ed, thanks again for your time today. I'll keep you posted as we continue to track down the root cause of this issue.
Ehren
- Ehren8 years agoMicrosoft Employee
Hi Ed. As I said over email, we've identified the root cause of this issue. We're currently targeting the fix for our July release.
In the meantime, you can work around the issue by ensuring that your folded queries are always sorted. This can be done by always including (and preserving in downstream queries) all primary keys for a given table. Or, if this isn't possible (as in your case when doing a Group By operation), you can explicitly sort by a set of unique keys before combining. (Also note that it may be necessary to buffer after sorting and before combining to ensure the sort is applied by the folding layer. You'll have to experiment to see whether or not this is necessary.)
Ehren
- Ehren8 years agoMicrosoft Employee
Ah, yes. You'll need the new gateway as well (once it comes out).
Ehren
- Ehren8 years agoMicrosoft Employee
Yes, this month is a little abnormal. :) I just checked and was told the July gateway should be out soon (in the next day or so).
Ehren
- Ehren8 years agoMicrosoft Employee
Hi edhans. Yes, it looks like you're hitting the issue described in the admin portal (which was an unintended side effect of the fix for the original issue you were hitting). Do you happen to know which region your PBI service is in? If so, I can let you know when the fix is deployed to your region.
Ehren
- Ehren8 years agoMicrosoft Employee
Also, if you're available to live debug this, please ask the folks handling your ticket to schedule a Skype meeting with me. Might be easier than going back-and-forth here on the forum.
Ehren
- Ehren8 years agoMicrosoft Employee
Another question: what version of SQL Server are you pulling from?
Ehren
- edhans8 years agoCommunity Champion
The SQL Queries are all pulling from SQL 2008 and simply connect to the tables. So:
let Source = SQL_DATA, Custom1 = Source{[Schema="dbo",Item="TableName"]}[Data] in Custom1My source is simply = Sql.Database("SQLSERVER", "DATABASE") - I do that so can change the server name in one place to do development work off of a different server.
Then there are a number of transformations, merges, etc.
I will tried the Buffer statement after the combine. After a few tests, it seems to have resolved it. The UNION and BUFFER tables consistenly report the same info, but the unbuffered one randomly gets out of whack. I ran 10 tests. F means the unbuffered table failed while the BUFFER and UNION tables worked, P means all 3 matched.
- P
- F
- F
- F
- F
- P
- P
- F
- P
- F
So you can see it is pretty random as to when it fails. These refreshes were done over a 15min period. Takes less than a minute usually for this to refresh via the Gateway.
This also just started the week of June 11, 2018 at the earliest. No changes to the reports here. Was published back in March and has been running fine. Only changes are updated gateway, and whatever MS does on the backend to its service.Using table.buffer here could work as query folding was stopped a few stages before the Table.Combine, but I understand that kills query folding. Not looking forward to having to use table.buffer after appends if it kills query folding thereafter.
If that is good enough for helping you, let me know. If not, I will do the more detailed buffering on specific table and other tests.I am avail to live debug. I ran some yesterday with tech support and they gathered Fiddler data. Is that what you mean or is there a more detailed process. The ticket is Ticket #:10593214 and is being tracked under emails with REG:118062218446002 in the subject.
- Ehren8 years agoMicrosoft Employee
Thanks, edhans. That's useful info.
Here's one more thing you could try: when running locally in PBIDesktop, you can (sort of) simulate what happens in the service by ensuring the Data Privacy firewall is enabled and marking all your data sources as Private. If you get rid of the Table.Buffer and get your queries back into their prior, refreshing-in-the-service-produces-bad-results state, what happens when you enable the firewall locally, set all your data sources to private, and refresh? I'm curious if this will cause the issue to happen locally in PBIDesktop.
Ehren
- edhans8 years agoCommunity Champion
Here is what I did:
- Changed Global Options|Privacy to "Combine data according to each file's privacy levels." (it is just SQL Server here, one database, so one source)
- Changed Current File privacy to "Combine data according to your priacy level settings for each source"
- Edit Queries: Data Source Settings
- Cleared Permissions
- Edited the permissions for the Server/Database to Private
- Hit Refresh
- Authenticated again (domain, so just hit connect for the Windows Current Credentials)
- Refreshed about 10 times. Never failed the way it does in the service.
REdid the above but #1 at the top, changed global options to "Always Combine data according to privacy level for each source" (again, 1 source, so only one privacy level I suspect)
Repeated steps 2-6 as above.
About 10 refreshes. Worked every time. Never failed.Changed everything back to "ignore privacy levels." :-)
- Ehren8 years agoMicrosoft Employee
Ok. Just to clarify: when you did the buffering, were you buffering the result of the Table.Combine, or buffering each query before combining them?
Ehren
- edhans8 years agoCommunity Champion
One buffer, immediately after the Table.Combine. Not the whole thing, but this is the M code:
let Source = Table.Combine({qryOESLSHST, SalesCurMonth}), Buffer = Table.Buffer(Source), #"Trimmed Cus_No and Item_No" = Table.TransformColumns(Buffer,{{"cus_no", Text.Trim}, {"item_no", Text.Trim}}), - edhans8 years agoCommunity Champion
Hoping the team got in touch with you Ehren. Spent nearly an hour convincing them it wasn't the workspace, my browser, and renaming and republishing the report also wasn't the fix.
Honestly, if you need me to dump these tables into a different database so you can restore it into SQL 2008 let me know. - Ehren8 years agoMicrosoft Employee
I haven't seen anything. Can you please point them to this thread and ask them to add me to the email thread with you? I've met with two other customers who are experiencing this and would like to live debug some things with you.
Ehren
- edhans8 years agoCommunity Champion
I'll do it again, but I sent the link to them already yesterday and we even read through some of it today.
She and her manager said there were a lot of "ehren" in the Skype directory and stopped there. :shrug emoticon:
Edit: Done. Sent 3:45pm pacific. Hopefully they get in touch with you.
- Aron_Moore8 years agoSolution Specialist
We're experiencing similar behaviour with our SAP HANA report.
Sometimes the values displayed in our financial reports double but a manual refresh of the data seems to fix it. It's random and a pain to monitor and/or duplicate...
- Ehren8 years agoMicrosoft Employee
Hi Aron_Moore. SAP HANA uses a different backend pipeline than SQL, so yours is likely a different issue (although it's possible the root cause is similar). Can you create a new Power BI Community thread for it?
Thanks,
Ehren
- Aron_Moore8 years agoSolution Specialist
I had a thread but hadn't received any input yet. Thought I'd tag along with this one for some ideas/help.
https://community.powerbi.com/t5/Service/Data-duplication/m-p/451485#M47670
- Ehren8 years agoMicrosoft Employee
edhans, This issue should be now be fixed. Please download the Power BI Desktop July release and let us know if things are now working as expected.
Ehren
- edhans8 years agoCommunity Champion
Ehren wrote:
edhans, This issue should be now be fixed. Please download the Power BI Desktop July release and let us know if things are now working as expected.
Ehren
Thanks! Already have. So republish and I'm done? No new Gateway needed as well?
- edhans8 years agoCommunity Champion
Thanks. I'll wait until that happens before I make changes to my process. Hopefully soon. Usually the gateway is out by last week of month. Of course, normally desktop is out first or second week of month, and that was later than normal this time.
- edhans8 years agoCommunity Champion
I kinda figured this issue was part of the "abnormality" :smileyvery-happy:
- edhans8 years agoCommunity Champion
Ehren I am not sure if this is the same issue or not.
You may recall in my tests I had a PBIX file loaded into my personal workspace that tested three scenarios:
- The original report that came from a Table.Combine() that was first experiencing the bug.
- A new table created in DAX by bringing in the two tables separately and then using UNION()
- A new table that was the original Table.Combine() from #1 above that then had a Table.Buffer() after it.
When the new gateway was released last week, I installed it, then for grins republished this report to my workspace and let it go, expecting to never hear from it. It was set to alert me if any of the 3 values above wasn't the same.
Today it alerted me. The Table.Buffer() version is way way way off. Instead of a total of 10,570 rows that #1 and #2 have above, it only has 1,402 rows. Instead of the last 12 months, it only has August 2017, Sept 2017, and August 2018. It dropped Oct 2017-July 2018. That data was pulled from the same source table as Aug-Sep 2017.
The Aug 2018 data is in a separate table in our server and that is what gets appended.
This report has run several times a day for the last week with no issues, and today, it blew up. Let me know if you want the PBIX file or something. I downloaded it from the service when I got the alert. It has already refreshed automatically again and all 3 are in sync.
Or maybe the rollout isn't finalized? I just saw PB145321 in the Office 365 Admin portal.Status:Service degradationUser impact:Users may see missing or incomplete data when refreshing reports, viewing reports or dashboards.Latest message:Title: Incomplete or missing data User Impact: Users may see missing or incomplete data when refreshing reports, viewing reports or dashboards. More info: Customers utilizing specific connectors when refreshing datasets without using native SQL queries, pulling SQL data that does not include a SQL primary key column in the final result, and doing Append or Merge operations may experience this issue. The following is a list of connectors impacted: SQL Server, Oracle, PostgreSQL, MySQL, Teradata, Sybase, Informix, DB2 or Access. Current status: We've initiated the deployment of the fix to the affected environment. We anticipate the deployment process completing by the end of this week. Scope of impact: Impact is specific to a subset of users who are served through the affected infrastructure. Start time: Friday, July 13, 2018, at 10:08 PM UTC Preliminary root cause: A recent update to the Power BI services resulted in missing or incomplete data when refreshing reports, viewing reports or dashboards in some scenarios. Next update by: Friday, August 3, 2018, at 7:00 PM UTC