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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ameerehs
Frequent Visitor

Limit data on import

Hi there,

 

What can I add to filter my data before it is imported into power bi. Currently I have a filter once the data is imported but my power bi has become very slow and laggy. See below for my query. Any help would be appreciated. Thanks

 

let
Source = Sql.Database("POLGUELPH02WFDB", "PolyconIntegrative"),
dbo_p_igr_historian_data = Source{[Schema="dbo",Item="p_igr_historian_data"]}[Data],
#"Filtered Rows" = Table.SelectRows(dbo_p_igr_historian_data, each Date.IsInPreviousNDays([TIMESTAMP], 35)),
#"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each true),
#"Added Conditional Column" = Table.AddColumn(#"Filtered Rows1", "Custom", each if Text.Contains([PLCSHORTTAGNAME], "F1.vaI_Iavg")

3 REPLIES 3
edhans
Super User
Super User

First, delete the Filtered Rows1 step. It is doing nothing.

 

As to why your query is laggy, not sure. The filter should be folding to the server. When I created a filter to limit it to the last 15,000 days (just messing around) I can right-click on that filter and View Native Query has this in it:

 

...
where [_].[Due Date] >= convert(datetime2, '1980-06-12 00:00:00') and [_].[Due Date] < convert(datetime2, '2021-07-07 00:00:00')

So the server is filtering the data. For you it should be just doing 35 days.

I am not sure what the next step is doing. It might or might not fold but you cut it off.  This is not a valid statement:

Table.AddColumn(#"Filtered Rows1", "Custom", each if Text.Contains([PLCSHORTTAGNAME], "F1.vaI_Iavg")

You are missing a closing paren

You cannot have an if statement without both a then and else clause. Text.Contains is folding, but what is in your then/else clause might not be.

However, your query should be folding through the filtering, so if it is laggy, then even for 35 days, you may have millions of records.

 

Make sure your column profiling at the bottom of your screen says 1,000 rows, not "all data."

edhans_0-1625697989674.png

To help further, we'd need to see the full formula in the Table.AddColumn() step, as well as know if your filter is folding. Again, right-click on it, and see if View Native Query is available.

edhans_1-1625698064966.png

 

 





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

my full query is quite long as I am doing more filtering and rearranging of columns after..However while the query does filter by 35 days, when I apply changes it still loads over 20 million records, while 35 days are only 4.5 million

Then it isn't filtering correctly, but without data or something to look at, I cannot say. It isn't a bug, it is the way the filter is being used. Unfortunately I cannot help further without some hard data to look at, like the native query generated by the filter.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

Top Solution Authors
Top Kudoed Authors