March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
I have a monthly sales data in the last 3 years. I would like to create line chart that shows monthly sales in the last 3 years.
What would be the measure to exclude the current month, or to exclude if the month is still not finished? Thanks.
For example, for the 2024, since June is still not finished, the 2024 chart line should stop in the month of May.
Solved! Go to Solution.
Hi @Oros ,
You just nned to apply filter in your DAX Measure
Sales_Excluding_Current_Month =
VAR CurrentMonth = MONTH(TODAY())
VAR CurrentYear = YEAR(TODAY())
RETURN
CALCULATE(
SUM(Sales[SalesAmount]),
FILTER(
Sales,
YEAR(Sales[Date]) < CurrentYear ||
(YEAR(Sales[Date]) = CurrentYear && MONTH(Sales[Date]) < CurrentMonth)
)
)
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!
@Oros
you should use a date table/Calender table and use the measure below.
Total Sales =
VAR CurrentMonth = MAX('Date'[Date])
VAR LastMonth = CALCULATE(MAX('Date'[Date]), ALL('Date'))
RETURN
IF(
CurrentMonth = LastMonth,
BLANK(), -- Exclude current month if it's the last available month
CALCULATE(
SUM('Sales'[SalesAmount]),
FILTER(
ALL('Date'),
'Date'[Date] <= LastMonth -- Include months up to the last completed month
)
)
)
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
@Oros
you should use a date table/Calender table and use the measure below.
Total Sales =
VAR CurrentMonth = MAX('Date'[Date])
VAR LastMonth = CALCULATE(MAX('Date'[Date]), ALL('Date'))
RETURN
IF(
CurrentMonth = LastMonth,
BLANK(), -- Exclude current month if it's the last available month
CALCULATE(
SUM('Sales'[SalesAmount]),
FILTER(
ALL('Date'),
'Date'[Date] <= LastMonth -- Include months up to the last completed month
)
)
)
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
Hi @Oros ,
You just nned to apply filter in your DAX Measure
Sales_Excluding_Current_Month =
VAR CurrentMonth = MONTH(TODAY())
VAR CurrentYear = YEAR(TODAY())
RETURN
CALCULATE(
SUM(Sales[SalesAmount]),
FILTER(
Sales,
YEAR(Sales[Date]) < CurrentYear ||
(YEAR(Sales[Date]) = CurrentYear && MONTH(Sales[Date]) < CurrentMonth)
)
)
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!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
23 | |
16 | |
12 | |
9 | |
7 |
User | Count |
---|---|
38 | |
32 | |
28 | |
12 | |
11 |