Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello community.
I have created a formula that should return the measure based on previous date. The formula is as follows.
VAR PeriodEnd = FIRSTDATE(Dates[Date])-1
VAR PeriodStart =
PeriodEnd -
DATEDIFF (
FIRSTDATE(Dates[Date]),
LASTDATE(Dates[Date]),
DAY
)
VAR Result =
CALCULATE(
[Dækningsgrad nuværende],
DATESBETWEEN(
Dates[Date],
PeriodStart,PeriodEnd
)
)
RETURN
Result
In my mind that should return my measure [Dækningsgrad nuværende] based on my Dates table. -1 period. And if i change (-1) with (-2) that should return my measure minus two periods. However it is not working.
If i set my dates as the following. Last period show 99,02%, but if i change to last period which in this instance would be 01-01-2020 - 31-12-2020
In the above example my measure "Dækningsgrad lastperiod" in 2020 should have returned as "Dækningsgrad 2nd last period" in 2021. Whereas second last period should be 2019.
Dækningsgrad 2nd last period =
VAR PeriodEnd = FIRSTDATE(Dates[Date])-2
VAR PeriodStart =
PeriodEnd -
DATEDIFF (
FIRSTDATE(Dates[Date]),
LASTDATE(Dates[Date]),
DAY
)
VAR Result =
CALCULATE(
[Dækningsgrad nuværende],
DATESBETWEEN(
Dates[Date],
PeriodStart,PeriodEnd
)
)
RETURN
Result
Can you see what could be wrong?
Thanks in advance.
Solved! Go to Solution.
@Anonymous , refer if these can help
same period based on date range
Last Period =
var _max =maxx(allseleceted(date),date[date])
var _min =maxx(allseleceted(date),date[date])
var datediff1 = datediff(_min,_max,day)
var _maxX = _max-datediff1
var _minX = _min -datediff1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))
same period based on date range year behind
Last Period =
var _max =maxx(allseleceted(date),date[date])
var _min =maxx(allseleceted(date),date[date])
var datediff1 = datediff(_min,_max,day)
var _maxX = eomonth(_max,-12)+1
var _minX = eomonth(_min,-12)+1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))
Hi @Anonymous,
Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.
If these also don't help, please share more detailed information to help us clarify your scenario to test.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
@Anonymous , refer if these can help
same period based on date range
Last Period =
var _max =maxx(allseleceted(date),date[date])
var _min =maxx(allseleceted(date),date[date])
var datediff1 = datediff(_min,_max,day)
var _maxX = _max-datediff1
var _minX = _min -datediff1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))
same period based on date range year behind
Last Period =
var _max =maxx(allseleceted(date),date[date])
var _min =maxx(allseleceted(date),date[date])
var datediff1 = datediff(_min,_max,day)
var _maxX = eomonth(_max,-12)+1
var _minX = eomonth(_min,-12)+1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
100 | |
72 | |
44 | |
38 | |
29 |
User | Count |
---|---|
156 | |
92 | |
62 | |
44 | |
41 |