cancel
Showing results for
Did you mean:
Member

## Sale in first three days Dax

Hi All,

I am stuck in the following Dax calculation, hope you could help.

I have two tables

Table 1 has details of a product launch date

 Product Launch date Mobile 09-08-2017 Laptop 01-08-2017 Shirt 08-08-2017 Jeans 04-08-2017

Table 2 on Product sale from launch date

 Product Date Daily Sale Mobile 09-08-2017 891 Mobile 10-08-2017 599 Mobile 11-08-2017 828 Mobile 12-08-2017 977 Mobile 13-08-2017 521 Mobile 14-08-2017 695 Laptop 01-08-2017 787 Laptop 02-08-2017 646 Laptop 03-08-2017 693 Laptop 04-08-2017 917 Laptop 05-08-2017 781 Laptop 06-08-2017 674 Laptop 07-08-2017 679 Laptop 08-08-2017 998 Laptop 09-08-2017 930 Laptop 10-08-2017 744 Laptop 11-08-2017 859 Laptop 12-08-2017 667 Laptop 13-08-2017 617 Laptop 14-08-2017 844 Shirt 08-08-2017 606 Shirt 09-08-2017 678 Shirt 10-08-2017 772 Shirt 11-08-2017 783 Shirt 12-08-2017 718 Shirt 13-08-2017 793 Shirt 14-08-2017 894 Jeans 04-08-2017 696 Jeans 05-08-2017 765 Jeans 06-08-2017 964 Jeans 07-08-2017 784 Jeans 08-08-2017 869 Jeans 09-08-2017 745 Jeans 10-08-2017 566 Jeans 11-08-2017 765 Jeans 12-08-2017 839 Jeans 13-08-2017 659 Jeans 14-08-2017 875

I am trying to find out the sale for each product in the first 3 days from launch.

I have used this formula to calculate

CALCULATE([Total Earning],FILTER(ALL(Table2[Date]),MAX(Table1[Release Date])<=Table2[Date]+3)) something similar to Sumifs we do in normal excel

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Sale in first three days Dax

Hi @baronraghu,

I have made a setup of ytou table in wich the tables are related by the Product and added the following measure:

```Sales_3 days =
VAR date_launch =
MAX ( Product_Lauch[Launch date] )
RETURN
CALCULATE (
SUM ( Product_Sales[Daily Sale] ),
Product_Sales[Date]
<= date_launch + 3
)```

This gives me the following result:

I have added the launch date in the summary table but you can you your measure direclty in a chart/card/etc.. no need to have the date or any other filter as you can see above.

Regards,

MFelix

Proud to be a Datanaut!

3 REPLIES 3
Super User

## Re: Sale in first three days Dax

Hi @baronraghu,

I have made a setup of ytou table in wich the tables are related by the Product and added the following measure:

```Sales_3 days =
VAR date_launch =
MAX ( Product_Lauch[Launch date] )
RETURN
CALCULATE (
SUM ( Product_Sales[Daily Sale] ),
Product_Sales[Date]
<= date_launch + 3
)```

This gives me the following result:

I have added the launch date in the summary table but you can you your measure direclty in a chart/card/etc.. no need to have the date or any other filter as you can see above.

Regards,

MFelix

Proud to be a Datanaut!

Member

## Re: Sale in first three days Dax

Hi @MFelix

I was getting this error that Calculate function is returning a true/false value which is not allowed. Is this because I am not using DAX studio and missed out something?

I had written Calculate (sum(table2(daily Sales)),Table2[Date]),Table2<=Max(Table1[Launch date])+2)

I tried using this formula and it worked out for me

Calculate( Sum(Table2(Daily Sale)),Filter(All(Table2[Date]),Table2<=Max(Table1[Launch date])+2)

Regards

Highlighted
Super Contributor

## Re: Sale in first three days Dax

Hi @baronraghu,

Great to hear the problem got resolved! Could you accept the corresponding reply as solution to close this thread?

Regards