Forum Discussion

Nico83's avatar
Nico83
Regular Visitor
1 year ago
Solved

Struggling to get the average

Hi there   I am hoping that someone is able to point me in the right direction. I have tried various formulas and measures and cannot seem to get the coloum to give me the average number of calls. ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Nico83 , hello Ritaf1983, thank you for your prompt reply!

    Please check if the following measures meet your requirements:

    Average Inbound Calls = 
    VAR SelectYear = SELECTEDVALUE('Table'[DATE].[Year])  
    VAR SelectMonth = SELECTEDVALUE('Table'[Month])       
    VAR SelectDay = SELECTEDVALUE('Table'[DATE].[Day])    
    VAR LastDayOfMonth = EOMONTH(DATE(SelectYear, SelectMonth, 1), 0)  
    VAR DaysInMonth = DAY(LastDayOfMonth)                 
    VAR DaysInYear = DATEDIFF(DATE(SelectYear, 1, 1), DATE(SelectYear, 12, 31), DAY)  
    
    RETURN 
    SWITCH(
        TRUE(),
        NOT(ISBLANK(SelectDay)), 
            CALCULATE(COUNTROWS('Table'), 'Table'[INBOUND] = "Inbound") / 1,  
        NOT(ISBLANK(SelectMonth)), 
            CALCULATE(COUNTROWS('Table'), 'Table'[INBOUND] = "Inbound") / DaysInMonth,  
        NOT(ISBLANK(SelectYear)), 
            CALCULATE(COUNTROWS('Table'), 'Table'[INBOUND] = "Inbound") / DaysInYear,  
        BLANK()
    )
    
    Average Outbound Calls = 
    VAR SelectYear = SELECTEDVALUE('Table'[DATE].[Year]) 
    VAR SelectMonth = SELECTEDVALUE('Table'[Month])       
    VAR SelectDay = SELECTEDVALUE('Table'[DATE].[Day])    
    VAR LastDayOfMonth = EOMONTH(DATE(SelectYear, SelectMonth, 1), 0)  
    VAR DaysInMonth = DAY(LastDayOfMonth)                
    VAR DaysInYear = DATEDIFF(DATE(SelectYear, 1, 1), DATE(SelectYear, 12, 31), DAY)  
    
    RETURN 
    SWITCH(
        TRUE(),
        NOT(ISBLANK(SelectDay)), 
            CALCULATE(COUNTROWS('Table'), 'Table'[OUTBOUND] = "Outbound") / 1,  
        NOT(ISBLANK(SelectMonth)), 
            CALCULATE(COUNTROWS('Table'), 'Table'[OUTBOUND] = "Outbound") / DaysInMonth,  
        NOT(ISBLANK(SelectYear)), 
            CALCULATE(COUNTROWS('Table'), 'Table'[OUTBOUND] = "Outbound") / DaysInYear,  
        BLANK()
    )
    

    Result:

    Best regards,

    Joyce

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Nico83 , 

    Thank you for your feedback.

     

    Per my test, I created month, year and day numeric columns for the slicer:

    You could also change the SelectMonth variable in both measures as shown below without creating these columns:

    VAR SelectMonth = SELECTEDVALUE('Table'[DATE].[MonthNo])       
    

     

    Best regards,

    Joyce

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.