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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jd8766
Helper II
Helper II

Measure to bring previous year total sales?

Hi everyone, I have a table that looks like the below.. it's a basic sales table which shows sales, sale date, order date and other information such as product and sale channel..

jd8766_2-1653659701879.png

 

 

What I want to build is a matrix that shows me the product, sales channel and then the number of sales for the selected sale date period. This part is easy and I have already done it... however I then want to add another figure to show me the TOTAL sales in the previous 12 months by the [OrderDate], split by the product and the sales channel.. something like this..


jd8766_1-1653659478857.png


So the PrevYearTotal will be a count of the sales prior to the end of the previous [OrderDate] month (so if I looked at it today, it would show the total sales with an [OrderDate] between 30/04/2021 and 30/04/2022. This figure will only ever change once we go into a new calendar month.

Can anyone advise the best way to achieve this?



 

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

Hi, @jd8766 ;

You could try it.

PrevYearTotal = CALCULATE(SUM('Table'[Salekey]),FILTER(ALL('Table'),[OrderDate]<=EOMONTH(TODAY(),-1)&&[OrderDate]>EOMONTH(TODAY(),-13)))

The final show:

vyalanwumsft_0-1653965879768.png


Best Regards,
Community Support Team _ Yalan Wu
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-yalanwu-msft
Community Support
Community Support

Hi, @jd8766 ;

You could try it.

PrevYearTotal = CALCULATE(SUM('Table'[Salekey]),FILTER(ALL('Table'),[OrderDate]<=EOMONTH(TODAY(),-1)&&[OrderDate]>EOMONTH(TODAY(),-13)))

The final show:

vyalanwumsft_0-1653965879768.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@jd8766 , Join both of them with same date table. and use date/period in visual/slicer from the date table 

 

Assume the order date is inactive 

 

calculate( calculate( SUM(Sales[Sales Amount]),USERELATIONSHIP ('Sales'[Order Date], 'Date'[Date])),DATESYTD(dateadd('Date'[Date],-1,Year)))

 

or

 

calculate( calculate( SUM(Sales[Sales Amount]),USERELATIONSHIP ('Sales'[Order Date], 'Date'[Date])),previousyear('Date'[Date]))

 

example

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in...

 

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.