Forum Discussion

Sofiane85's avatar
Sofiane85
Frequent Visitor
2 years ago
Solved

sales from different dates range

Hi all, i have 2 tables, "Sales" and "Target" in the Target table there is some of products and 2 dates columns : Start Date and End Date, please, i need to calculate the sales from "Sales" table,...
  • Fowmy's avatar
    2 years ago

    Sofiane85 

    Add following culumn to your target table:

    Sales = 
    VAR __Prod = Target[Product] 
    VAR __DateStart = Target[start date] 
    VAR __DateEnd = Target[end date] 
    VAR __Result = 
    SUMX(
        FILTER(
            Sales,
            Sales[Product] = __Prod &&
            Sales[Date] >= __DateStart && Sales[Date] <= __DateEnd 
        ),
        Sales[Qte]
    )
    RETURN
        __Result