cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## same months comparison over the years - DAX

Hi all!

i use this DAX

CY = CALCULATE(SUM('Market'[Sales]), DATESMTD('Calendar'[Date]))/1000;

and for the last year

the issue is when i select filter for example jan&feb 2024, it shows only value for February 2024 & 2023 accordingly. But i need a sum for of all selected months

Any suggestions?
1 ACCEPTED SOLUTION
Community Support

Hi @RT6

Thanks for the reply from @Dangar332 , please allow me to provide another insight:

My sample:

Create a measure as follows

``````comparison =
VAR _previous = CALCULATE(SUM(Market[Sales]), FILTER(Market, [Date] IN SAMEPERIODLASTYEAR('Calendar'[Date])))
VAR _current = CALCULATE(SUM(Market[Sales]), FILTER(ALL(Market), [Date] IN VALUES('Calendar'[Date])))
RETURN
DIVIDE(_previous + _current, 1000)``````

Result:

Best Regards,
Yulia Xu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 REPLIES 3
Community Support

Hi @RT6

Thanks for the reply from @Dangar332 , please allow me to provide another insight:

My sample:

Create a measure as follows

``````comparison =
VAR _previous = CALCULATE(SUM(Market[Sales]), FILTER(Market, [Date] IN SAMEPERIODLASTYEAR('Calendar'[Date])))
VAR _current = CALCULATE(SUM(Market[Sales]), FILTER(ALL(Market), [Date] IN VALUES('Calendar'[Date])))
RETURN
DIVIDE(_previous + _current, 1000)``````

Result:

Best Regards,
Yulia Xu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Frequent Visitor

hi Yulia,

thanks for your response! SAMEPERIODLASTYEAR worked well in this case 🙂

Super User

Hi, @RT6

you have slicer in month form and you want sum of month wise then use DATESYTD()

use DATESYTD instead of DATESMTD

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors