hi all,
I need help to calculted the total sales in the last 3 months by selecting slicer week. with the rules. If I choose week 6, the total sales displayed are the previous 3 months, namely November 2021 to January 2022.
How do I get the total value of last 3 months without months from the week slicer I chose. thank you
Solved! Go to Solution.
Hi @thians ,
When you refer that you want the last 3 months you can try something similar to this:
Totals Last 3 Months =
VAR FirstDateMonth =
DATE ( YEAR ( MIN ( 'Calendar'[Date] ) ), MONTH ( MIN ( 'Calendar'[Date] ) ), 1 ) - 1
RETURN
CALCULATE (
[Measure],
DATESINPERIOD ( 'Calendar'[Date], FirstDateMonth, -3, MONTH ),
ALL ( 'Calendar'[Date] )
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @thians ,
According to your description, I created two tables.
Relationship
Try these measure.
StartDate =
VAR DateFrom = MIN(CALENDAR[Date])
VAR numMonthsBack = 3
VAR StartDate = EOMONTH(DateFrom,(numMonthsBack+1)*-1)+1
RETURN StartDate
EndDate =
VAR DateFrom = MIN(CALENDAR[Date])
VAR numMonthsBack = 1
VAR EndDate = EOMONTH(DateFrom,numMonthsBack*-1)
RETURN EndDate
Total in last 3 Month =
var _startDate = [StartDate]
var _endDate = [EndDate]
return
CALCULATE (
SUM('Table'[Sales]),
FILTER ( ALL('Table'), 'Table'[Date] >= _startDate && 'Table'[Date] <= _endDate )
)
The result should be like this.
Attaching the pbix file for reference.
Best Regards,
Community Support Team _ Gao
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi @thians ,
According to your description, I created two tables.
Relationship
Try these measure.
StartDate =
VAR DateFrom = MIN(CALENDAR[Date])
VAR numMonthsBack = 3
VAR StartDate = EOMONTH(DateFrom,(numMonthsBack+1)*-1)+1
RETURN StartDate
EndDate =
VAR DateFrom = MIN(CALENDAR[Date])
VAR numMonthsBack = 1
VAR EndDate = EOMONTH(DateFrom,numMonthsBack*-1)
RETURN EndDate
Total in last 3 Month =
var _startDate = [StartDate]
var _endDate = [EndDate]
return
CALCULATE (
SUM('Table'[Sales]),
FILTER ( ALL('Table'), 'Table'[Date] >= _startDate && 'Table'[Date] <= _endDate )
)
The result should be like this.
Attaching the pbix file for reference.
Best Regards,
Community Support Team _ Gao
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi @thians ,
When you refer that you want the last 3 months you can try something similar to this:
Totals Last 3 Months =
VAR FirstDateMonth =
DATE ( YEAR ( MIN ( 'Calendar'[Date] ) ), MONTH ( MIN ( 'Calendar'[Date] ) ), 1 ) - 1
RETURN
CALCULATE (
[Measure],
DATESINPERIOD ( 'Calendar'[Date], FirstDateMonth, -3, MONTH ),
ALL ( 'Calendar'[Date] )
)
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsPower BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.
Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!
Join the biggest FREE Business Applications Event in LATAM this February.
User | Count |
---|---|
228 | |
52 | |
49 | |
47 | |
46 |
User | Count |
---|---|
279 | |
212 | |
113 | |
82 | |
73 |