The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Community,
I am trying to create previous month values. Everything is working as expected only issue is last date in Database is 5th April 2021 but when I select Date range slicer from 1st to 4th April so it gives me correct prevoius month value. BUT when I select date range from 1st April to 5th April so it gives me whole March value in previous measure.
I want it to give me 1st to 5th March value in my previous measure when I select date range from 1st to 5th April.
I don't know why it's behaving like this.
Solved! Go to Solution.
Hi @Uzi2019 ,
Did you create a relationship between the two tables?
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Syndicate_Admin ,
I create the following sample data, and then create a measure.
Ventas anteriores =
var MonthEnd =
CALCULATE(
SUM('DataTable'[Sales]),
DATEADD( 'Calendar'[Date], -1, MONTH )
)
var Month =
CALCULATE(
SUM('DataTable'[Sales]),
FILTER(
ALL('DataTable'),
'DataTable'[Date] <= EDATE( MAX('Calendar'[Date]), -1 )
&&'DataTable'[Date] >= EDATE( MIN('Calendar'[Date]), -1 )
)
)
var Result =
IF(
MAX('Calendar'[Date]) = EOMONTH( MAX('Calendar'[Date]), 0 ),
MonthEnd,
Month
)
return Result
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Syndicate_Admin ,
I create the following sample data, and then create a measure.
Ventas anteriores =
var MonthEnd =
CALCULATE(
SUM('DataTable'[Sales]),
DATEADD( 'Calendar'[Date], -1, MONTH )
)
var Month =
CALCULATE(
SUM('DataTable'[Sales]),
FILTER(
ALL('DataTable'),
'DataTable'[Date] <= EDATE( MAX('Calendar'[Date]), -1 )
&&'DataTable'[Date] >= EDATE( MIN('Calendar'[Date]), -1 )
)
)
var Result =
IF(
MAX('Calendar'[Date]) = EOMONTH( MAX('Calendar'[Date]), 0 ),
MonthEnd,
Month
)
return Result
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Syndicate_Admin , You can try like example
MTD QTY forced=
var _max = today()
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESMTD('Date'[Date])), blank())
//or
//calculate(Sum('order'[Qty]),DATESMTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALMTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))
LMTD QTY forced=
var _max = date(year(today()),month(today())-1,day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALMTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)
LYMTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESMTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALMTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)
Refer
Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA
Hi @Uzi2019 ,
Did you create a relationship between the two tables?
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Uzi2019
If it is OK with you, please share your sample pbix file, then I can try to look into it and come up with a fixed result.
Thank you.
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Thank you for reply. But cant share you pbix file for security reasons.