Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
What is the easiest way to get previous month from today's date? I want to filter dynamic report to previous month.
Query1= Date.Month
Query2=DateTime.LocalNow
Invoked function= (#"Query1"(Query2()))-1 gives me the value 2. But I am not able to attach it to the month.
Solved! Go to Solution.
Not sure if it is the easiest way but you could do something like this:
=#date(Date.Year(DateTime.LocalNow()),Date.Month(DateTime.LocalNow()) - 1,Date.Day(DateTime.LocalNow()))
Hi @Anonymous ,
Do you just wanna get the month,if so ,you can use an expression as below:
Previous month=If(Month(Datetime.LocalNow())-1=0,12,Month(Datetime.LocalNow())-1)
If you wanna get the date,you can use following expressions:
Previous date=If(Month(DateTime.LocalNow())-1=0,Date(Year(DateTime.LocalNow()),12,Day(DateTime.LocalNow()),Date(Year(DateTime.LocalNow()),Month(DateTime.LocalNow()) - 1,Day(DateTime.LocalNow()))
Or you can create a calendar table and create a relationship between the 2 table,finally using an expression as below:
DATEADD ('Calendar'[Date], -1, month)
If today is for the real date,you can use today() instead of DateTime.LocalNow().
Hi @Anonymous ,
Do you just wanna get the month,if so ,you can use an expression as below:
Previous month=If(Month(Datetime.LocalNow())-1=0,12,Month(Datetime.LocalNow())-1)
If you wanna get the date,you can use following expressions:
Previous date=If(Month(DateTime.LocalNow())-1=0,Date(Year(DateTime.LocalNow()),12,Day(DateTime.LocalNow()),Date(Year(DateTime.LocalNow()),Month(DateTime.LocalNow()) - 1,Day(DateTime.LocalNow()))
Or you can create a calendar table and create a relationship between the 2 table,finally using an expression as below:
DATEADD ('Calendar'[Date], -1, month)
If today is for the real date,you can use today() instead of DateTime.LocalNow().
DATEADD is the function to use for this. It does require a date format field for the date and is able to add or subtract day, month, quarter or year from a given value. Hope that helps
DATEADD (<dates>, <number_of_intervals>, <interval type>)
Not sure if it is the easiest way but you could do something like this:
=#date(Date.Year(DateTime.LocalNow()),Date.Month(DateTime.LocalNow()) - 1,Date.Day(DateTime.LocalNow()))
User | Count |
---|---|
77 | |
77 | |
68 | |
67 | |
49 |
User | Count |
---|---|
108 | |
105 | |
93 | |
83 | |
64 |