Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowDon'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,
I am new to Power BI and needs the solution of the following scenario.
As the picture above depicts i need a DAX formula for values to be summed for same month that is for september but not of current year rather previous year's septemeber.
Best Regards.
Solved! Go to Solution.
Hi @asgharkhan ,
You can try below DAX:
1. Using -365 Days method and no specific DAX function (This will cover multiple year scenario as well if selected in date slicer)
PY_YTD =
VAR Y =
YEAR ( CALCULATE ( MAX ( 'Calendar_Table'[Date] ) ) )
VAR a =
CALCULATE ( MIN ( 'Calendar_Table'[Date] ), 'Calendar_Table'[Year] = Y ) - 365
VAR b =
CALCULATE ( MAX ( 'Calendar_Table'[Date] ), 'Calendar_Table'[Year] = Y ) - 365
RETURN
CALCULATE (
SUM(DocAmount),
'Calendar_Table'[Date] >= a,
'Calendar_Table'[Date] <= b
)
2. Using SAMEPERIODLASTYEAR
PY_YTD =
CALCULATE(
SUM(DocAmount),
SAMEPERIODLASTYEAR('Calendar_Table'[Date])
)
3. Using DATEADD
PY_YTD =
CALCULATE(
SUM(DocAmount),
DATEADD('Calendar_Table'[Date], -1, Year)
)
Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!! Proud To Be a Super User !!! |
Hi @asgharkhan ,
You can try below DAX:
1. Using -365 Days method and no specific DAX function (This will cover multiple year scenario as well if selected in date slicer)
PY_YTD =
VAR Y =
YEAR ( CALCULATE ( MAX ( 'Calendar_Table'[Date] ) ) )
VAR a =
CALCULATE ( MIN ( 'Calendar_Table'[Date] ), 'Calendar_Table'[Year] = Y ) - 365
VAR b =
CALCULATE ( MAX ( 'Calendar_Table'[Date] ), 'Calendar_Table'[Year] = Y ) - 365
RETURN
CALCULATE (
SUM(DocAmount),
'Calendar_Table'[Date] >= a,
'Calendar_Table'[Date] <= b
)
2. Using SAMEPERIODLASTYEAR
PY_YTD =
CALCULATE(
SUM(DocAmount),
SAMEPERIODLASTYEAR('Calendar_Table'[Date])
)
3. Using DATEADD
PY_YTD =
CALCULATE(
SUM(DocAmount),
DATEADD('Calendar_Table'[Date], -1, Year)
)
Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!! Proud To Be a Super User !!! |
@asgharkhan You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000
Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...
But specifically this video has examples of various methods to do this:
hi, @asgharkhan
try below
adjust your table name
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your kudos
Thank You for the reply but unforntunatly it didn't solve the issue. In fact I need only sum of figures of previous year (2022) but upto the month same as current month (i.e September).
hi, @asgharkhan
use DATEADD function
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
146 | |
72 | |
63 | |
52 | |
51 |
User | Count |
---|---|
208 | |
91 | |
62 | |
59 | |
56 |