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.
Hi there,
I use the following measure to summarize the revenue for the current month:
CurrentMonthRevenue = CALCULATE(SUM(Order[Revenue]), FILTER(Order, MONTH(Order[Date])=MONTH(TODAY()))
And this measure for the previous month:
PreviousMonthRevenue= var current_month = month(TODAY()) return CALCULATE(SUM(Order[Revenue]), FILTER(Order, MONTH(Order[Date])= current_month -1))
However, this does not work when I am using a date slicer with the month of the years in it. I use a separate calender table.
How can I change this that the previous month revenue will be summarize based on the selected months in the slicer?
Now it calculates it for this month (November) and October, but if June and July are chosen in the slicer it has to calculate it for those months.
Thanks!
Solved! Go to Solution.
Hi @SG-01 ,
According to your description, it's because in the formula you provided, havn't take the Date slicer into consideration. Here's my solution.
Order table:
Date table:
Create two measures.
CurrentMonthRevenue =
CALCULATE (
SUM ( 'Order'[Revenue] ),
FILTER (
'Order',
MONTH ( 'Order'[Date] )
= IF (
ISFILTERED ( 'Date'[Month] ),
SELECTEDVALUE ( 'Date'[Month] ),
MONTH ( TODAY () )
)
)
)
PreviousMonthRevenue =
VAR current_month =
IF (
ISFILTERED ( 'Date'[Month] ),
SELECTEDVALUE ( 'Date'[Month] ),
MONTH ( TODAY () )
)
RETURN
CALCULATE (
SUM ( 'Order'[Revenue] ),
FILTER ( 'Order', MONTH ( 'Order'[Date] ) = current_month - 1 )
)
Result:
If there isn't month been selected in the slicer, it will return the current month and corresponding previous month.
If other month is selected in the slicer, it will return the selected month and corresponding previous month.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @SG-01 ,
According to your description, it's because in the formula you provided, havn't take the Date slicer into consideration. Here's my solution.
Order table:
Date table:
Create two measures.
CurrentMonthRevenue =
CALCULATE (
SUM ( 'Order'[Revenue] ),
FILTER (
'Order',
MONTH ( 'Order'[Date] )
= IF (
ISFILTERED ( 'Date'[Month] ),
SELECTEDVALUE ( 'Date'[Month] ),
MONTH ( TODAY () )
)
)
)
PreviousMonthRevenue =
VAR current_month =
IF (
ISFILTERED ( 'Date'[Month] ),
SELECTEDVALUE ( 'Date'[Month] ),
MONTH ( TODAY () )
)
RETURN
CALCULATE (
SUM ( 'Order'[Revenue] ),
FILTER ( 'Order', MONTH ( 'Order'[Date] ) = current_month - 1 )
)
Result:
If there isn't month been selected in the slicer, it will return the current month and corresponding previous month.
If other month is selected in the slicer, it will return the selected month and corresponding previous month.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @SG-01 ,
What is the name of your date table? You need to use the ALL function in last month's measure to escape from the slicer filtering.
Something like this (adapt to your table and field names). Also need to include year to set the current year
CALCULATE(SUM(Order[Revenue]), FILTER(ALL(Datetable), Datetable[MonthNumnber])= current_month -1))
Please consider accepting as solution if this answers the question.
No, I want to INCLUDE the slicer filtering in my measure. Based on the chosen months in the slicer the revenue for the current and previous months needs to be calculated.
you can use relative date in slicer and select last 1 calender months... then you will by default prior month revenue when ever you can open that report,, if you want current month means select this month in same slicer....
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 |
---|---|
99 | |
69 | |
46 | |
39 | |
33 |
User | Count |
---|---|
163 | |
110 | |
61 | |
51 | |
40 |