Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BPyL
New Member

Less records than in SQL view

Hi everybody.

 

I'm new in PowerBI but a SQL advanced user.

 

I have created a SQL View that shows 5 records. When I import this view link into PowerBI, it shows me only 2 records. 

 

These are the PoweBI resulting records:

 

PowerBI sólo muestra 2 registros de los 5.jpg

 

And these are the View result (View_Logistica_01), 5 records.

 

Origen de datos SQL.jpg

 

Does anybody can help me?

 

Thanks.

 

1 ACCEPTED SOLUTION
BPyL
New Member

It is solved.

 

Searching the sql queries that uses these sql views, I noticed the problem has appeared just on friday.

Why? The only answer possible was in the queries that are getting different data only on friday.

One of they is checking if the next day from GETDATE() is saturday, if so, it gets data from next monday. I use the DATENAME function, here is a query portion:

 

(CASE WHEN DATENAME(WEEKDAY, DATEADD(DAY, 1, GETDATE())) = 'Saturday' 
THEN 2 ELSE 0 END)

 

Well, when I run this query on friday in my sql server, it returns 'Saturday' but when PowerBI runs it, it returns the spanish name 'Sábado'. So, the records on next monday are not showed in PowerBI because the CASE statement is not true.

 

Finally I have changed the query above to this other:

(CASE WHEN DATENAME(WEEKDAY, DATEADD(DAY, 1, GETDATE())) IN ('Saturday', 'Sábado')
THEN 2 ELSE 0 END)

 

And it works.

 

Have a nice day.

 

View solution in original post

3 REPLIES 3
BPyL
New Member

It is solved.

 

Searching the sql queries that uses these sql views, I noticed the problem has appeared just on friday.

Why? The only answer possible was in the queries that are getting different data only on friday.

One of they is checking if the next day from GETDATE() is saturday, if so, it gets data from next monday. I use the DATENAME function, here is a query portion:

 

(CASE WHEN DATENAME(WEEKDAY, DATEADD(DAY, 1, GETDATE())) = 'Saturday' 
THEN 2 ELSE 0 END)

 

Well, when I run this query on friday in my sql server, it returns 'Saturday' but when PowerBI runs it, it returns the spanish name 'Sábado'. So, the records on next monday are not showed in PowerBI because the CASE statement is not true.

 

Finally I have changed the query above to this other:

(CASE WHEN DATENAME(WEEKDAY, DATEADD(DAY, 1, GETDATE())) IN ('Saturday', 'Sábado')
THEN 2 ELSE 0 END)

 

And it works.

 

Have a nice day.

 

rohit_singh
Solution Sage
Solution Sage

Hi @BPyL ,

I assume you have added the same queries to power query as in your screenshot. What I think might be happening is that power query is loading only the final query, which is view_logistica_01b, which is why you're seeing only two results. 
What you can do is append your SQL query with ; select * from view_logistica_01 so that this is the last statement. Maybe that gives you all the rows since the main table will be evaluated last.

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos!  🙂

 



Hi Rohit and thank you for your answer.

The only query I use in powerBI is the first one, view_logistica_01 with his 5 records. The other 2 queries are depending views, only if you want to see.

Finally, I think it seems to be a spanish date format issue, because the day number 13 is interpreted as month number 13. I will adjust the CONVERT function in the query and I will answer here again for a better community knowledge.

 

Kind regards

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors