Forum Discussion
Each data refresh gives different data results
Hi,
I'm experiencing the same issue as people are describing here. I'm using Power Query "append" but "merge" seems to do the same based on Ina's post. Let me demonstrate the problematic behavior using test data.
First, we need a query that returns the same data but in random order. I will use a MS SQL stored procedure but I think any DB query returning data in a different order every time we rerun it would do.
create procedure create_test_data(@max int = 0) as BEGIN WITH Pass0 as (select 1 as C union all select 1), --2 rows Pass1 as (select 1 as C from Pass0 as A, Pass0 as B),--4 rows Pass2 as (select 1 as C from Pass1 as A, Pass1 as B),--16 rows Pass3 as (select 1 as C from Pass2 as A, Pass2 as B),--256 rows Pass4 as (select 1 as C from Pass3 as A, Pass3 as B),--65536 rows Pass5 as (select 1 as C from Pass4 as A, Pass4 as B),--4294967296 rows big_table as (select row_number() over(order by C) as n from Pass5) select n, Abs(Checksum(NewId())) % 10 As RanInt from big_table where n <= @max order by RanInt END
Column RanInt is used to randomize the order. We will be using only column n that contains integers from 1 to Max and therefore sum(n) depends only on Max.
Second, I create two tables in Power BI Desktop. Both have the same definition:
Third, I create a new table in the Query Editor window using "Append Queries as New":
This generates Power query: Table.Combine({Query1, Query2})
As a last step, I create simple reports based on each of the two input tables Query1 and Query2 and table Append1 created in the previous step. I use count(n) and sum(n) as my metrics.
When refreshing the report (i.e. the underlying data), Query1 and Query2 returns correct results, Append1 returns correct number of records but incorrect sum.
Currently, I'm using version: 2.51.4885.701 64-bit (October, 2017) but the July version had the same issue. The older version allowed me to copy & paste data (from the left Data menu) so I could see what Ina is describing in another thread - records have been loaded 0-2 times. This makes me guess that Power BI is reading the data while it's being refreshed which causes the inconsistency when the data are loaded in different order than previously. Based on network traffic Power BI seems to execute the stored procedure 3 times. BTW why is it no longer possible to copy data from tables in the Data tab? That's a significant step backwards IMO.
You might need to increase the number of records generated by the stored procedure. In my environment, 1000 rows per query was ok but 10k rows caused incorrect results. Just hit “refresh” in the report window and you will see.
When using production data, sometimes even sum of Query1 produced incorrect results when all inputs were refreshed at once (refreshing just the single input was ok). However, I couldn’t simulate this using the test data. DAX union works well meaning there is a workaround within Power BI. However, even if this behavior is "feature" and not a bug, we need to understand what’s the cause and what else should we avoid but merging/appending data in Power Query to stay out of troubles.
Thanks,
Petr
- InaNortje8 years agoAdvocate I
Hi Petr_Strejc
Excellent description of the issue! Thank you very much for providing steps to recreate the issue.
I sent a request to Chis Webb to have a look at this issue. Of all the people I know, he is most familiar with Power Query and M, and he has good contacts at Microsoft who may take up the issue.
Another person that may be able to help is Koen Verbeeck.
Regards
Ina
- hbarber8 years agoRegular Visitor
Hi there,
Has there been any update on this?
I have just created a report on PowerBI but each time I've refreshed it today I get a different total.
The underlying data is pulling from SQL tables which are updated overnight so that data is not changing inbetween refreshes.
Initially it took 7 refreshes to get the figure I was expecting but then I just kept refreshing to see how many times it would take to get that figure again and it took 18 times, then 7 again.
Any help would be greatly appreciated!
Thanks
Harriet
- Matty8 years agoHelper II
Hi,
Any news on this?
I don't know how prevalent the issue is, but it feels like a fairly fundamental problem that needs addressing.
Cheers,
Matty
- Anonymous8 years agoNot applicable
I've had this same issue.
Sometimes I even get an error message saying there was a duplicate value in one of my tables. I then refresh again and it pulls through, but as before, the data is giving different numbers
Really feels like it's doing something different everytime I click refresh
- kdecolve8 years agoRegular Visitor
Hello
I figured out that there was a problem with the merge query.
I solved this by merging the tables in SQL Server.
- Anonymous8 years agoNot applicable
Hi kdecolve do you have any more detail on how you found the problem? I'd rather stick to merging my queries in Query Editor rather than in SQL Server.