Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

@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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors