cancel
Showing results for
Did you mean:
Regular Visitor

## Dax related to last year starting to current date of last year

Hello Everyone,

I need to calculate sales of Last year from starting 01.01.2021 to current date of last year i.e 20.05.2021

In below dax I can calculate only for 01.01.2021 to 20.05.2021

Sales (LY) =
CALCULATE (
[USD_NetSales],
FILTER (
ALL ( Dim_Date ),
Dim_Date[Year] = YEAR ( TODAY () )-1
&& Dim_Date[Month] = MONTH ( TODAY () )
&& Dim_Date[Date] <= DATE( YEAR( TODAY () )-1, MONTH( TODAY() ), DAY( MAX(Dim_Date[Date])
)
)
))

Please guide me what modification shall I do to get sales for 01.01.2021 to 20.05.2021 instead of 01.05.2021 to 20.05.2021

1 ACCEPTED SOLUTION
Super User

Hi,

I will look into the filter context inside the CALCULATE function.

In the current DAX measure, there is one condition that sets month number as the same as today's month number.  Please try to remove that condition.

I hope this helps to rewrite a measure to show the result that you want.

Thanks.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

5 REPLIES 5
Super User

Hi,

Try this measure

Sales (LY) = CALCULATE([USD_NetSales],datesbetween(calendar[date],date(year(today())-1,1,1),edate(today(),-12)))
Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Super User

Hi,

I will look into the filter context inside the CALCULATE function.

In the current DAX measure, there is one condition that sets month number as the same as today's month number.  Please try to remove that condition.

I hope this helps to rewrite a measure to show the result that you want.

Thanks.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Regular Visitor

Thank you Sir. It worked ..

Memorable Member

(1) Solved: Total of last year on the same period as this year... - Microsoft Power BI Community

Last Year Sale =  CALCULATE(SUM(tablename[SalesAmount]), SAMEPERIODLASTYEAR(DateTable[Date]))

Regards,

Ritesh

Regular Visitor

Thank you for your response.. I will try this measures too.

Announcements