Forum Discussion

SES78's avatar
SES78
Regular Visitor
6 years ago
Solved

Date formula

I need to create a formula that will allow me to look at data from one date MINUS data from another date.

i.e. what is the difference in $ between Sunday, December 2 and Monday, December 3.  I would like this to be a dynamic formula as each day I need to see the detail between the current snapshot and the Sunday snapshot.  The next in line would be the difference in $ between Dec 2 - Tues Dec 4, etc, etc This is done by week, on a daily basis.

Any help would be greatly appreciated!

  • Try something like this:

     

    DynamicSalesDifference = 
    var TodaySales = Calculate(Sum(FactInternetSales[SalesAmount]), DimDate[Date] =Today())
    var SundaySales = Calculate(Sum(FactInternetSales[SalesAmount]), WEEKNUM(DimDate[Date]) = WEEKNUM(Today()) && WEEKDAY(DimDate[Date]) = 1 && Year(DimDate[Date]) = YEAR(TODAY()))
    return TodaySales - SundaySales

     

    Replace all  FactInternetSales[SalesAmount] and DimDate[Date] with your own fields.

     

    Regards

2 Replies

  • Try something like this:

     

    DynamicSalesDifference = 
    var TodaySales = Calculate(Sum(FactInternetSales[SalesAmount]), DimDate[Date] =Today())
    var SundaySales = Calculate(Sum(FactInternetSales[SalesAmount]), WEEKNUM(DimDate[Date]) = WEEKNUM(Today()) && WEEKDAY(DimDate[Date]) = 1 && Year(DimDate[Date]) = YEAR(TODAY()))
    return TodaySales - SundaySales

     

    Replace all  FactInternetSales[SalesAmount] and DimDate[Date] with your own fields.

     

    Regards