Forum Discussion

CJMolin's avatar
CJMolin
Icon for Helper II rankHelper II
8 years ago
Solved

Historical comparison on weekday - level basis

Hello,

 

I have a pretty big problem which I couldnt really solve by my own.

 

I have a huge dataset with several KPI's. I would like to be able to benchmark the historical result of these KPIs each weekday with the current result.

 

Example:

I would like to measure how many contracts I have sent out in average the last 3 weeks on a week day basis

Eg: 

Historical Mon week 1= 100

Historical Mon week 2= 200

Historical Mon week 3= 300

 

Historical Average past 3 weeks = 200

 

Current week Mon week 4 = 300, which means 50% increase compared to the previous 3 weeks average.

 

My dataset looks something like below. I'm first trying to get the acumulated sum of contracts sent out previous 14 days. But If i calculate the second columns it doesnt really exactly add up to the third columns aggregated total.

 

DAX measure used: 

test = CALCULATE([sales];FILTER(ALL(Dim_Calendar[Date]);Dim_Calendar[Date]<=MAX('Application'[DateDocsCustomer])&&Dim_Calendar[Date]>MAX('Application'[DateDocsCustomer])-14);USERELATIONSHIP(Dim_Calendar[Date];'Application'[DateDocsCustomer]))

 

2017-10-22673581
2017-10-21703717
2017-10-202553581
2017-10-193293581
2017-10-183603657
2017-10-174013581
2017-10-163603657
2017-10-15883729
2017-10-14983701
2017-10-133103581
2017-10-123553657
2017-10-113623657
2017-10-103903657
2017-10-094103581
2017-10-08953998
2017-10-07653605
2017-10-062683657
2017-10-054023657
2017-10-044233720
2017-10-034543657
2017-10-024213657
2017-10-01684094
2017-09-30793605
2017-09-293013657
2017-09-284123729
2017-09-273973701
2017-09-264123897
2017-09-253543581
2017-09-24674029
2017-09-23544094
2017-09-222693605
2017-09-213483960
2017-09-203604064
2017-09-193654012
2017-09-184393701

 

Please help me!

  • Hi CJMolin,

     

    From above example, which one is [Sales] column? Why do you need to calculate the acumulated sum of contracts in last 14 days?

     

    I am not very clear about your requirement, please show us your ddesired result with examples. Based on my assumption, I created below formula to get the average value every 3 weeks.

    WeekNum = WEEKNUM('Application'[DateDocsCustomer])
    WeekDay = WEEKDAY('Application'[DateDocsCustomer],2) 
    
    Average last three weeks =
    CALCULATE (
        AVERAGE ( 'Application'[Sales] ),
        FILTER (
            'Application',
            'Application'[WeekNum] <= EARLIER ( 'Application'[WeekNum] )
                && 'Application'[WeekNum]
                    > EARLIER ( 'Application'[WeekNum] ) - 3
                && 'Application'[WeekDay] = EARLIER ( 'Application'[WeekDay] )
        )
    )

     

    Best regards,
    Yuliana Gu

4 Replies

    • CJMolin's avatar
      CJMolin
      Icon for Helper II rankHelper II

      Hi Greg_Deckler,

       

      Thanks. I am well aware of these functions. Although the problem I have is to get an average sum of [sales] the last x number of mondays,tuesdays etc etc.. As stated in the example in the description.

       

      • v-yulgu-msft's avatar
        v-yulgu-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        Hi CJMolin,

         

        From above example, which one is [Sales] column? Why do you need to calculate the acumulated sum of contracts in last 14 days?

         

        I am not very clear about your requirement, please show us your ddesired result with examples. Based on my assumption, I created below formula to get the average value every 3 weeks.

        WeekNum = WEEKNUM('Application'[DateDocsCustomer])
        WeekDay = WEEKDAY('Application'[DateDocsCustomer],2) 
        
        Average last three weeks =
        CALCULATE (
            AVERAGE ( 'Application'[Sales] ),
            FILTER (
                'Application',
                'Application'[WeekNum] <= EARLIER ( 'Application'[WeekNum] )
                    && 'Application'[WeekNum]
                        > EARLIER ( 'Application'[WeekNum] ) - 3
                    && 'Application'[WeekDay] = EARLIER ( 'Application'[WeekDay] )
            )
        )

         

        Best regards,
        Yuliana Gu