Sales dollars between two dates

BORUCH

Well-known Member
Joined
Mar 1, 2016
Messages
548
Office Version
  1. 365
Platform
  1. Windows
hi all
i have my sales history table with approx. 10 mil rows of invoice and credit memo history
it has columns like customer number, customer name ,invoice number, invoice date ,item number, item description ,qty ,amount ... etc..

what I'm trying to do is have a formula that gives me sales between two dates that i want to select in a slicer so i created two disconnected date tables one of them is called P1 Compare From Date the other is called P1 Compare To Date then i have a formula in my sale history table as follows Total Sales$ Sold From -- to P1:=SUMX(FILTER('salesdata', 'salesdata'[Invoice Date] >= MIN('P1 Compare From Date'[Date]) && 'salesdata'[Invoice Date] <= MAX('P1 Compare To Date'[Date])), 'salesdata'[AMOUNT])

the problem is it runs extremely slow and i have a very quick computer any help or recommendations would be appreciated
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You are on the right track but you need some changes. One issue is that you are using a Virtual filter. There are no relationships between your tables meaning the engine basically has to trawl through millions of rows to find the data. You have to do it, but there are better ways. Do the following

1. Get a calendar table

2. Use it as shown in this article The Optimal Shape for Power BI Data joining it to the date column in your transaction table.

3. Then you put your filter on the calendar table, not the transaction table

Rich (BB code):
=
CALCULATE (
    SUM ( 'salesdata'[AMOUNT] ),
    FILTER (
        'Calendar',
        'Calendar'[Date] >= MIN ( 'P1 Compare From Date'[Date] )
            && 'Calendar'[Date] <= MAX ( 'P1 Compare To Date'[Date] )
    )
)

Using calculate ensures that only the data you need remains before the calculation starts; this is best practice
 
Upvote 0
Solution
You are on the right track but you need some changes. One issue is that you are using a Virtual filter. There are no relationships between your tables meaning the engine basically has to trawl through millions of rows to find the data. You have to do it, but there are better ways. Do the following

1. Get a calendar table

2. Use it as shown in this article The Optimal Shape for Power BI Data joining it to the date column in your transaction table.

3. Then you put your filter on the calendar table, not the transaction table

Rich (BB code):
=
CALCULATE (
    SUM ( 'salesdata'[AMOUNT] ),
    FILTER (
        'Calendar',
        'Calendar'[Date] >= MIN ( 'P1 Compare From Date'[Date] )
            && 'Calendar'[Date] <= MAX ( 'P1 Compare To Date'[Date] )
    )
)

Using calculate ensures that only the data you need remains before the calculation starts; this is best practice
thanks that worked
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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