Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello
I have a 2 year sales table (previous year to this day).
Example: today is 22/01/2022
I want to filter in power Query the column "FECHA_VENTA" in such a way to get only the sales from:
- from January 1 of the Current Year to Diadehoy/mesactual/current year (that is, from 01/01/2022 to 22/01/2022))
- and the same period but last year:
- from January 1 of the YearAnterior to Diadehoy/mesactual/añoaPrevious (that is, from 01/01/2021 to 22/01/2021)
you can please help me to correctly put these conditions in the date filter
Solved! Go to Solution.
Hi @Syndicate_Admin ,
Here I suggest you to create a custom column by M code and then filter your table by this column. DateTime.LocalNow can help you get today's datetime, it is dynamic.
M Code:
Custom Filter
=
if
(
Date.Year ([FECHA_VENTA])= Date.Year ( DateTime.LocalNow())
or
Date.Year ([FECHA_VENTA]) = Date.Year ( DateTime.LocalNow()) -1
)
and
Date.Month([FECHA_VENTA]) <= Date.Month (DateTime.LocalNow())
and
Date.Day([FECHA_VENTA]) <= Date.Day (DateTime.LocalNow())
then "Ture"
else "False"
Then select "True" in [Custom Filter] column.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Syndicate_Admin ,
Here I suggest you to create a custom column by M code and then filter your table by this column. DateTime.LocalNow can help you get today's datetime, it is dynamic.
M Code:
Custom Filter
=
if
(
Date.Year ([FECHA_VENTA])= Date.Year ( DateTime.LocalNow())
or
Date.Year ([FECHA_VENTA]) = Date.Year ( DateTime.LocalNow()) -1
)
and
Date.Month([FECHA_VENTA]) <= Date.Month (DateTime.LocalNow())
and
Date.Day([FECHA_VENTA]) <= Date.Day (DateTime.LocalNow())
then "Ture"
else "False"
Then select "True" in [Custom Filter] column.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I am not sure you can do this in power query. Can you just bring back the last 2 years data and then manage the last year and this year combinations using dax in your measures?
you could probably create a function to do this but i think it would be a custom function.
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
99 | |
73 | |
72 | |
49 |
User | Count |
---|---|
145 | |
109 | |
109 | |
90 | |
64 |