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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Chrono9084
New Member

Best way to speed up a report by limiting data? Filtering dates on a pattern?

My goal is to limit the data that PowerBI is working with to help my report load faster and work better.

 

The Data

My data currently comes in the form of a spreadsheet emailed daily from our server.  It looks like this:

#Software NameVersionLast UserMachine NameLast Sync
1AutoCAD Civil 3D 2011 64 Bit Object Enabler on Autodesk Revit Architecture 2011 x64 - Language Neutral1477   
2AutoCAD Civil 3D 2011 64 Bit Object Enabler on Autodesk Revit Structure 2011 x64 - Language Neutral1477   
3Autodesk 360 Structural Analysis plug-in for Autodesk Revit 20132013.0.0.337   
4Autodesk Advance Steel 2015.1 Extension for Autodesk Revit15.2.0.0   
5Autodesk Advance Steel 2019 Extension for Autodesk Revit19.1.106.0That GuyWINSURBJP08/10/2021 06:58:19
6Autodesk Advance Steel 2019 Extension for Autodesk Revit19.1.106.0Some User 2LHD57P1308/09/2021 22:34:04
7Autodesk Advance Steel 2019 Extension for Autodesk Revit19.1.106.0Some UserLFBDFP7308/09/2021 16:56:01

 

Because the file name is the same every day, I have Power Automate copying these files from my email every day and putting them on sharepoint while also renaming them with the current date such that the filename looks like this: 20200810NameOfFile.xls (that is YYYYMMDD date format).

 

The final step is having PowerBI join these files using a Query where it grabs the entire folder, filters out files that do not apply, creates a new column and applies the files date to each line from that file (this is required as the last sync date has nothing to do with the date of the report).

 

My Goal

I would like the query to do two things:

  1. Keep the last month of data (all days).
  2. Filter all remaining data and keep one day from each week (basically reducing older historical data by 86%).

 

Thanks in advance!

 

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Chrono9084 ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Add a custom column to get the dates which filter the conditions(dates from last month and one day from each week), otherwise it return null

Note: I just keep the dates which the day of date is on Monday and dates from last month, you can adjust the condition base on your scenario....

yingyinr_0-1628755260997.png

2. Filter the new column with the dates are not null

yingyinr_2-1628755543736.png

The full applied codes as below:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("xZXbboJAEIZfZeJ1hT1w9A5PPcRYozW9MF6gbpWGQsPB6Nt3Fk1T2NYmFmsg2U3Y+b9h5h+YzRq0cdPw8izueF3oBNsgBN4FRigFy4B2kMHj4lUsM+hF/iIUCcQRyOMrkcJYbPG5lyw3QYZH8kQcAncY2YSBH61zfy1gKPIs8UPkUMO2cTne85tZg/2VPsmS/Dw0P6KlFrfIp5Ifghf54T4NUngP83UziOAlTipcpEkBuWgEL84r8sYXeW+19aOlQIQQoQw1NQq9XSaiNIi/UZf5mhqTwmVR85So+5ukq1GNEqsQfdr4Gdzme9w+3w8n03H7YYR7R6dEZ4Rh/VumUzCt2piT+E3ANMU2yrYP7rqmPSqq6OjuAcpYixsF1a6fKpn9drc/sktMim9qFUznWqNg68yqJuNeZTIwE7uaCSUXmxRkOQqOnmr9GZODEKXVlNXmrx8mydY5Uai8fldXZwm5VOEa13M2VWtvXsvaakOsS1pb7cPJr9p51mYKxLm8tRlXqO5/WJsZVS4j9XPLPwqkmiXq/AM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"#" = _t, #"Software Name" = _t, Version = _t, #"Last User" = _t, #"Machine Name" = _t, #"Last Sync" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"#", Int64.Type}, {"Software Name", type text}, {"Version", type text}, {"Last User", type text}, {"Machine Name", type text}, {"Last Sync", type datetime}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Max date", each if Date.Year([Last Sync])
        = Date.Year(List.Max(#"Changed Type"[Last Sync])) and Date.Month([Last Sync])
        = Date.Month(List.Max(#"Changed Type"[Last Sync]))
      then
        [Last Sync]
      else if Date.DayOfWeek([Last Sync]) = 1 then
        [Last Sync]
      else
        null),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Max date] <> null))
in
    #"Filtered Rows"

yingyinr_1-1628755515794.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @Chrono9084 ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Add a custom column to get the dates which filter the conditions(dates from last month and one day from each week), otherwise it return null

Note: I just keep the dates which the day of date is on Monday and dates from last month, you can adjust the condition base on your scenario....

yingyinr_0-1628755260997.png

2. Filter the new column with the dates are not null

yingyinr_2-1628755543736.png

The full applied codes as below:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("xZXbboJAEIZfZeJ1hT1w9A5PPcRYozW9MF6gbpWGQsPB6Nt3Fk1T2NYmFmsg2U3Y+b9h5h+YzRq0cdPw8izueF3oBNsgBN4FRigFy4B2kMHj4lUsM+hF/iIUCcQRyOMrkcJYbPG5lyw3QYZH8kQcAncY2YSBH61zfy1gKPIs8UPkUMO2cTne85tZg/2VPsmS/Dw0P6KlFrfIp5Ifghf54T4NUngP83UziOAlTipcpEkBuWgEL84r8sYXeW+19aOlQIQQoQw1NQq9XSaiNIi/UZf5mhqTwmVR85So+5ukq1GNEqsQfdr4Gdzme9w+3w8n03H7YYR7R6dEZ4Rh/VumUzCt2piT+E3ANMU2yrYP7rqmPSqq6OjuAcpYixsF1a6fKpn9drc/sktMim9qFUznWqNg68yqJuNeZTIwE7uaCSUXmxRkOQqOnmr9GZODEKXVlNXmrx8mydY5Uai8fldXZwm5VOEa13M2VWtvXsvaakOsS1pb7cPJr9p51mYKxLm8tRlXqO5/WJsZVS4j9XPLPwqkmiXq/AM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"#" = _t, #"Software Name" = _t, Version = _t, #"Last User" = _t, #"Machine Name" = _t, #"Last Sync" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"#", Int64.Type}, {"Software Name", type text}, {"Version", type text}, {"Last User", type text}, {"Machine Name", type text}, {"Last Sync", type datetime}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Max date", each if Date.Year([Last Sync])
        = Date.Year(List.Max(#"Changed Type"[Last Sync])) and Date.Month([Last Sync])
        = Date.Month(List.Max(#"Changed Type"[Last Sync]))
      then
        [Last Sync]
      else if Date.DayOfWeek([Last Sync]) = 1 then
        [Last Sync]
      else
        null),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Max date] <> null))
in
    #"Filtered Rows"

yingyinr_1-1628755515794.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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