March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
In power query, I want to limit the amount of data loaded into the model by only including new data within the last 3 months from the excel. So far found this forums, however it doesnt work with my case. Solved: Include only Latest 3 months of data - Microsoft Power BI Community
Example:
I use this filter to filter the Production Month column to only load the latest 3 months data.
= Table.SelectRows(#"Renamed Columns", each Date.IsInPreviousNMonths([Production Month], 3))
For addition info,
- I have production data from Jan 2019 to Jun 2022
- my initial data was in excel format
- my final option is to just filter the excel by only put in the latest 3 month data, however in future when there is new month for new data, I need to replace the source of the excel with updated one manually.
Solved! Go to Solution.
Hi @firdaus62 ,
Please try this.
= Table.SelectRows(#"Changed Type", each [Date] > Date.AddMonths(Date.EndOfMonth(List.Max(#"Changed Type"[Date])),-3) and [Date] <= Date.EndOfMonth(List.Max(#"Changed Type"[Date])))
All steps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdhBDt1WDEPRvWRcwCKfZdlrCbr/bRRB2pRXQ458vog/ePz584cuXS7rx99//QrOcDLcGTrDk2EyvBm+DCokGASEoBAYgkOACBKBIlgMi3kPWAyLYTEshsWwGBbDcmA5YfGF4Awnw52hMzwZJsOb4cNHC4kgIASFwBAcAkSQCBTBYljMe8BiWAyLYTEshiWLOnn+k+c/ef6T5z95/pPnP3n+c+E7Hz5aSDAICEEhMASHABEk4k+GxbCY94DFsBgWw2JYDAvPb1gOLPk/uS8EZzgZ7gyd4ckwGd4MHz5aSAQBISgEhuAQIIJEoAgWw2LeAxbDYlgMi2ExLIbFsGRRndV0VtNZTWc1ndV0VtNZTWc1ndU0qmlU06imUU2jmkY1jWoa1TSqaVTTqKZRTaOaRjWNahrVNKppVNOoplFNr2ryP/RcCM5wMtwZOsOTYTK8GT58tJAIAkJQCAzBIUAEiUARLIbFvAcshsWwGBbDYlgMi2HJoiarmaxmsprJai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fDho4VEEBCCQmAIDgEiSASKYDEs5j1gMSyGxbAYFsNiWAzLgSWL+i4EZzgZ7gyd4ckwGd4MHz5aSAQBISgEhuAQIIJEoAgWw2LeAxbDYlgMi2ExLIbFsOAFVHidFp6nhfdp4YFaeKEWnqiFN2rhkVp4pRafqcV3avGhWnypFp+qxbdq8bFafK0Wn6vF92qhrj8r3/+RKlNlqkyVqTJVpspUreLyLyauDJwZuDNwaODSwKmBWwPHBq4Na25Ye8MaHNbisCaHtTms0WGtDmt2WLvDGh7W8rCmh7U9rPFhrQ9rflj7wxog1gKxJgisDv+tfH/SQbqRGulBGqQX6ePXF4YakSN6RJAoEkmiSUSJKlPldSOqTJWpMlWmylSZKlO1isMf8HeN59/gDCfDnaEzPBkmw5vhy/C7vT8JBgEhKASG4BAggkSgCBbDYt4DFsNiWAyLYTEshsWwHFhOWHwhOMPJcGfoDE+GyfBm+PDRQiIICEEhMASHABEkAkWwGBbzHrAYFsNiWAyLYcmiTp7/5PlPnv/k+U+e/+T5T57/XPjOh48WEgwCQlAIDMEhQASJ+JNhMSzmPWAxLIbFsBgWw8LzG5YDS/5P7gvBGU6GO0NneDJMhjfDh48WEkFACAqBITgEiCARKILFsJj3gMWwGBbDYlgMi2ExLFlUZzWd1XRW01lNZzWd1XRW01lNZzWNahrVNKppVNOoplFNo5pGNY1qGtU0qmlU06imUU2jmkY1jWoa1TSqaVTT/1fz9z8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Date] > Date.AddMonths(Date.EndOfMonth(List.Max(#"Changed Type"[Date])),-3) and [Date] <= Date.EndOfMonth(List.Max(#"Changed Type"[Date])))
in
#"Filtered Rows"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Try this dax
SalesLast3Months = CALCULATE(SUM(Sales[Amount]), DATESINPERIOD('Calendar'[Date], LASTDATE('Calendar'[Date]), -3, MONTH))
Give a Kudos
Hi & thanks for replying,
Below is the table that I have, my intention is to filter the data just to show latest 3 months of data so that all my report will reflect to show the latest 3 months data.
Hi @firdaus62 ,
Please try this.
= Table.SelectRows(#"Changed Type", each [Date] > Date.AddMonths(Date.EndOfMonth(List.Max(#"Changed Type"[Date])),-3) and [Date] <= Date.EndOfMonth(List.Max(#"Changed Type"[Date])))
All steps.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XdhBDt1WDEPRvWRcwCKfZdlrCbr/bRRB2pRXQ458vog/ePz584cuXS7rx99//QrOcDLcGTrDk2EyvBm+DCokGASEoBAYgkOACBKBIlgMi3kPWAyLYTEshsWwGBbDcmA5YfGF4Awnw52hMzwZJsOb4cNHC4kgIASFwBAcAkSQCBTBYljMe8BiWAyLYTEshiWLOnn+k+c/ef6T5z95/pPnP3n+c+E7Hz5aSDAICEEhMASHABEk4k+GxbCY94DFsBgWw2JYDAvPb1gOLPk/uS8EZzgZ7gyd4ckwGd4MHz5aSAQBISgEhuAQIIJEoAgWw2LeAxbDYlgMi2ExLIbFsGRRndV0VtNZTWc1ndV0VtNZTWc1ndU0qmlU06imUU2jmkY1jWoa1TSqaVTTqKZRTaOaRjWNahrVNKppVNOoplFNr2ryP/RcCM5wMtwZOsOTYTK8GT58tJAIAkJQCAzBIUAEiUARLIbFvAcshsWwGBbDYlgMi2HJoiarmaxmsprJaiarmaxmsprJaiarGVQzqGZQzaCaQTWDagbVDKoZVDOoZlDNoJpBNYNqBtUMqhlUM6hmUM2gmlnV5H/ovRCc4WS4M3SGJ8NkeDN8+GghEQSEoBAYgkOACBKBIlgMi3kPWAyLYTEshsWwGBbDcmDJor4LwRlOhjtDZ3gyTIY3w4ePFhJBQAgKgSE4BIggESiCxbCY94DF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/+RKlNlqkyVqTJVpspUreLyLyauDJwZuDNwaODSwKmBWwPHBq4Na25Ye8MaHNbisCaHtTms0WGtDmt2WLvDGh7W8rCmh7U9rPFhrQ9rflj7wxog1gKxJgisDv+tfH/SQbqRGulBGqQX6ePXF4YakSN6RJAoEkmiSUSJKlPldSOqTJWpMlWmylSZKlO1isMf8HeN59/gDCfDnaEzPBkmw5vhy/C7vT8JBgEhKASG4BAggkSgCBbDYt4DFsNiWAyLYTEshsWwHFhOWHwhOMPJcGfoDE+GyfBm+PDRQiIICEEhMASHABEkAkWwGBbzHrAYFsNiWAyLYcmiTp7/5PlPnv/k+U+e/+T5T57/XPjOh48WEgwCQlAIDMEhQASJ+JNhMSzmPWAxLIbFsBgWw8LzG5YDS/5P7gvBGU6GO0NneDJMhjfDh48WEkFACAqBITgEiCARKILFsJj3gMWwGBbDYlgMi2ExLFlUZzWd1XRW01lNZzWd1XRW01lNZzWNahrVNKppVNOoplFNo5pGNY1qGtU0qmlU06imUU2jmkY1jWoa1TSqaVTT/1fz9z8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Date] > Date.AddMonths(Date.EndOfMonth(List.Max(#"Changed Type"[Date])),-3) and [Date] <= Date.EndOfMonth(List.Max(#"Changed Type"[Date])))
in
#"Filtered Rows"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
16 | |
13 | |
12 | |
9 |
User | Count |
---|---|
36 | |
31 | |
20 | |
19 | |
17 |