cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rimi_2095
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

 

@amitchandak @SpartaBI @Ashish_Mathur @DataInsights @Jihwan_Kim @johnt75 @ribisht17 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
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.


Go to My LinkedIn Page


View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
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
https://www.linkedin.com/in/excelenthusiasts/
Jihwan_Kim
Super User
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.


Go to My LinkedIn Page


Thank you Sir. It worked ..

ribisht17
Memorable Member
Memorable Member

@Rimi_2095 

(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

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

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors