Display Last Weeks Data Dynamically Based On Date selection in slicer

Aradhika

New Member
Joined
Jul 20, 2019
Messages
11
Hi Team,

I have requirement in my project such as if i select "OrderDate"
From Slicer then based on that date last week sales data should populate in visual.
Example:
Suppose:
If i select 4/12/2020 in slicer then last week data should populate from that date.
If i select 11/22/2019 in slicer then last week data should populate from that date.

Columns i have is Order_date, Sales - Only two columns i am using...

I've created a couple of DAX Measures. However, that measure is calculating all weeks inspite of 1 Week.

Thanks for any help you can provide. You've been great.
AD
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try sumifs, range is less than date in slicer, range is greater than/equal to date in slicer less 7 (days).
 
Upvote 0
Hi,

Thank you for your quick response....

I've tried but no luck...

Below is the DAX which i have written :

= CALCULATE(SUM(Orders[Sales]),FILTER(ALL(Orders[OrderNewDate]),Orders[OrderNewDate]<=MAX(Orders[OrderNewDate])))


Still its not working...

Please provide DAX if it is possible... as i'm new in Power BI

Regards,
Ravi
 
Upvote 0
Hi Aradhika,

Just to confirm what your objective is - once you select a date from a slicer (e.g. 23/04/2020), do you want the table to show:
  1. the last week's data (16-22 April), as in 7 separate data points, or
  2. the sum of last week's data (16-22 April), so that only one (total) value will be displayed
?
 
Upvote 0
Hi JustynaMK,

Thank you for your reply...

If i select any date(single) from a slicer e.g. 23/04/2020 or 18/04/2020, I want a table or single card to display...

Sum of last week's data (16-22 April) ....
And if select 18/04/2020 then
Sum of last week's data (12-17 April) ....


Once again thank you
Aradhika
 
Upvote 0
Thanks for explaining! I think you can try this measure -

Rich (BB code):
mSumOrders = 
    var SelectedDate = SELECTEDVALUE(Orders[OrderNewDate])
return
    CALCULATE(
        SUM(Orders[Sales]),
        FILTER(ALL(Orders[OrderNewDate]), 
            Orders[OrderNewDate] < SelectedDate &&
            Orders[OrderNewDate] >= SelectedDate - 7)
    )

Here's the result for 23rd of April:

1587842161453.png


And for 18th of April (please note that it sums 11-17 April, as it extracts -7 days from the selected date):

1587842227003.png
 
Upvote 0
Hi JustynaMK,

Sorry for the late reply.... Due to some medical emergency i did not had access to my emails.

Thank you very much for the DAX.

I will use this in my project and let you know the results....

Regards,
Ravi
 
Upvote 0
Hi Ravi - no problem at all! I hope everything is well with you.

Let me know if you need further help with the formula (no rush).
 
Upvote 0
Excellent Above DAX is Working Great...

I need a little change. For example - If i select a date from a slicer and i should get last 3 months sales as separate data points for 3 months.
and 3 months data only one(total) in single card.

Many Thanks,
Aradhika
 
Upvote 0

Forum statistics

Threads
1,223,792
Messages
6,174,611
Members
452,574
Latest member
hang_and_bang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top