Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a requirement to load dynamically last three months based on max data available in Power Bi Dataflow
For example,This is April month but i have max snapshot date as Feb 2029 so i need to load from Dec,Jan and Feb.
If March data is loaded dynamically it will load Jan,feb and Mar .
Solved! Go to Solution.
Alright. Following the example let me show you how to do it:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCg1W0lEyMjAyMTAyslSK1YlW8nSBiRgaG4JFgt0hIsaGRlARD2+YiKGxgVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [COuntry = _t, Snapshotdate = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"COuntry", type text}, {"Snapshotdate", Int64.Type}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Snapshotdate", type text}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Changed Type1",{"Snapshotdate", type date}),
// New Code down here
var_last3months = Date.AddMonths(List.Max(#"Changed Type2"[Snapshotdate]), -3),
var_last3calendarmonths = Date.AddMonths(Date.StartOfMonth(List.Max(#"Changed Type2"[Snapshotdate])),-2),
#"Filtered Rows" = Table.SelectRows(#"Changed Type2", each [Snapshotdate] >= var_last3calendarmonths)
// New Code finishes here
in
#"Filtered Rows"
Take a look at the last 3 lines.
I have created two variables that you can choose depending on what you mean with "last 3 months".
The Step "Filtered Rows" is the one finally filtering by last 3 months with the variable. You can filter Snapshotdate by the one you have chosen.
I hope that make sense.
Happy to help!
Hi, if you can query the source with SQL go with karthik suggestion. Otherwise you can get the date and filter your data with the following power query
Date.AddMonths( [DateFromToSubstractDays] ,-3)
In case you want to get las 3 months from today, you can use "DateTime.FixedLocalNow()" for the date.
Regards,
Happy to help!
I have created sample data
where and how to apply this formula in M query editor.
My query editor looks like this now,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCg1W0lEyMjAyMTAyslSK1YlW8nSBiRgaG4JFgt0hIsaGRlARD2+YiKGxgVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [COuntry = _t, Snapshotdate = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"COuntry", type text}, {"Snapshotdate", Int64.Type}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Snapshotdate", type text}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Changed Type1",{"Snapshotdate", type date})
in
#"Changed Type2"
Alright. Following the example let me show you how to do it:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCg1W0lEyMjAyMTAyslSK1YlW8nSBiRgaG4JFgt0hIsaGRlARD2+YiKGxgVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [COuntry = _t, Snapshotdate = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"COuntry", type text}, {"Snapshotdate", Int64.Type}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Snapshotdate", type text}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Changed Type1",{"Snapshotdate", type date}),
// New Code down here
var_last3months = Date.AddMonths(List.Max(#"Changed Type2"[Snapshotdate]), -3),
var_last3calendarmonths = Date.AddMonths(Date.StartOfMonth(List.Max(#"Changed Type2"[Snapshotdate])),-2),
#"Filtered Rows" = Table.SelectRows(#"Changed Type2", each [Snapshotdate] >= var_last3calendarmonths)
// New Code finishes here
in
#"Filtered Rows"
Take a look at the last 3 lines.
I have created two variables that you can choose depending on what you mean with "last 3 months".
The Step "Filtered Rows" is the one finally filtering by last 3 months with the variable. You can filter Snapshotdate by the one you have chosen.
I hope that make sense.
Happy to help!
Thanks for your help .It worked out .
Create a Table/Query (SELECT Date FROM datatable where Date <= (somedate) with all dates needed for Dataflow and Merge the query with this query for Dataflow
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!