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
srkase
Helper IV
Helper IV

Sales as on date last year

Hi all

DATEYEARMINOR GROUPPRODUCTDEALERAPRMAYJUNJULAUGSEPOCTNOVDECJANFEBMARTOTAL QTYTOTALVALmonth
 20212022ASMSP425PSA110000000000015570APR
 20212022MINI3SHA112000000000001235205APR
 20212022MINI3SHA2100000000000115648APR
 20212022MINI4SHA2100000000000116549APR
 20212022MINI4SHA3300000000000362442APR
 20212022MINI5SHA4100000000000121715APR
 20212022CBCBCCA5100000000000122076APR
 20212022CBCBCCA1200000000000250267APR
 20212022CBCBCCA1100000000000125980APR
 20212022ASMSP425PSA210000000000015570DEC
 20212022MINI3SHA212000000000001235205DEC
 20212022MINI3SHA3100000000000115648DEC
 20212022MINI4SHA4100000000000116549DEC
 20212022MINI4SHA5300000000000362442DEC
 20212022MINI5SHA1100000000000121715DEC
 20212022CBCBCCA1100000000000122076DEC
 20212022CBCBCCA2200000000000250267DEC
 20212022CBCBCCA2100000000000125980DEC
 20222023ASMSP425PSA310000000000015570APR
 20222023MINI3SHA4200000000000235205APR
 20222023MINI3SHA5300000000000315648APR
 20222023MINI4SHA1400000000000416549APR
 20222023MINI4SHA1500000000000562442APR
 20222023MINI5SHA2600000000000621715APR
 20222023CBCBCCA2700000000000722076APR
 20222023CBCBCCA3800000000000850267APR
 20222023CBCBCCA4900000000000925980APR
 20222023ASMSP425PSA51000000000000105570DEC
 20222023MINI3SHA111000000000001135205DEC
 20222023MINI3SHA112000000000001215648DEC
 20222023MINI4SHA213000000000001316549DEC
 20222023MINI4SHA214000000000001462442DEC
 20222023MINI5SHA315000000000001521715DEC
 20222023CBCBCCA416000000000001622076DEC
 20222023CBCBCCA517000000000001750267DEC
 20222023CBCBCCA118000000000001825980DEC

 

The above is my data.  I need to calculate the sales as on date.  

ie.,,,as on today for the previous years...

 

Last year Sales = CALCULATE(SUM(PROD_CABLE[TOTALCR]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"3/31"))
 
but this takes sales upto december 31st .. when the measure is applied .... my fin year is from apr-march..  I need to show the sales upto todays date for the previous year...
 
I have created a date table also..
 
Thanks in advance..
 
REgards
 
SRK
 
 
 
 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @srkase ,

According to your description, the data you provided seems not related to the formula you provided. So I create a sample.
PROD_CABLE table:

vkalyjmsft_0-1669687573632.png

Calendar table:

vkalyjmsft_1-1669687660785.png

The two tables are related with Date column.

Here's my solution, create two measures.

YTD =
IF (
    MAX ( 'PROD_CABLE'[TOTALCR] ) = BLANK (),
    BLANK (),
    CALCULATE ( SUM ( 'PROD_CABLE'[TOTALCR] ), DATESYTD ( 'Date'[Date], "3/31" ) )
)
Last year Sales =
CALCULATE ( [YTD], DATEADD ( 'Date'[Date], -1, YEAR ) )

Get the result:

vkalyjmsft_2-1669687819165.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

3 REPLIES 3
v-yanjiang-msft
Community Support
Community Support

Hi @srkase ,

According to your description, the data you provided seems not related to the formula you provided. So I create a sample.
PROD_CABLE table:

vkalyjmsft_0-1669687573632.png

Calendar table:

vkalyjmsft_1-1669687660785.png

The two tables are related with Date column.

Here's my solution, create two measures.

YTD =
IF (
    MAX ( 'PROD_CABLE'[TOTALCR] ) = BLANK (),
    BLANK (),
    CALCULATE ( SUM ( 'PROD_CABLE'[TOTALCR] ), DATESYTD ( 'Date'[Date], "3/31" ) )
)
Last year Sales =
CALCULATE ( [YTD], DATEADD ( 'Date'[Date], -1, YEAR ) )

Get the result:

vkalyjmsft_2-1669687819165.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

speedramps
Super User
Super User

Hi 

 

Firsly you need to format the data from monthly columns into row values.

see how here https://community.powerbi.com/t5/Desktop/How-do-I-split-the-source-data-week-ranges-into-days-accord...

 

then use a calandar table with offsets

Click here to do free Power BI calendar training 

Especially do the offset training.

 

You can then slice and dice by offset.  For example

 

Sales = yourtable[amount]

 

This year sales = CACULATE( [Sales],  'Calendar'[yearoffset] =0) 

Last year sales = CACULATE( [Sales],  'Calendar'[yearoffset] =-1) 

 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remember we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

 

 

 

 

But I have huge volume of data in my table.... will take hours to process this... Is there any other alternative?

 

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.