Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi all,
I have a table that is currently looking at data from 2021 in column TRANSACTION_DATE.
I would like to filter this in Power Query M to Transaction_Date is >= 2 years previous (which will change next year to 2024, 2025, 2026 etc), so would see 2023, 2024 and 2025 this year.
Cannot figure out how to do this within the applied steps formula.
Your help would be appreciated.
Many Thanks
Alex
Solved! Go to Solution.
Managed to find the solution....
Table.SelectRows(#"Changed Type", each [TRANSACTION_DATE] >= DateTime.Date(Date.AddYears(DateTime.LocalNow(),-2)))
Hi @villa1980 ,
In power query, please add a new custom column using this M code to get the year:
Date.Year([TRANSACTION_DATE])
Now in APPLIED STEPS, right click in last step and inser step after with this M code:
= Table.SelectRows(#"Added Custom", each [Custom] >= Date.Year(DateTime.LocalNow()) - 2)
This will dynamically adjust each year and include data for the last two years plus the current year.
Hi @villa1980 ,
In power query, please add a new custom column using this M code to get the year:
Date.Year([TRANSACTION_DATE])
Now in APPLIED STEPS, right click in last step and inser step after with this M code:
= Table.SelectRows(#"Added Custom", each [Custom] >= Date.Year(DateTime.LocalNow()) - 2)
This will dynamically adjust each year and include data for the last two years plus the current year.
Managed to find the solution....
Table.SelectRows(#"Changed Type", each [TRANSACTION_DATE] >= DateTime.Date(Date.AddYears(DateTime.LocalNow(),-2)))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
89 | |
86 | |
68 | |
51 | |
32 |
User | Count |
---|---|
126 | |
112 | |
72 | |
64 | |
46 |