Forum Discussion

AndHan's avatar
AndHan
Frequent Visitor
5 years ago

Hourly Average based on selected days

Hi all

 

I'm having some problems when I try to show the average number of events throughout the day based on number of selected days.

I've created 2 measures:

- One that sums all my events

- One that calculates number of days selected

 

The measure that calculate the number of selected days seems to calculate the correct answer (in this example 3), but when I divide my data with this measure it seems like it doesn't work as I expected. I have highligted where it goes wrong.

 

What am I doing wrong? 

When I try to just divide my measure with the data with the number 3 it looks like expected.

6 Replies

  • vanessafvg's avatar
    vanessafvg
    Icon for Community Champion rankCommunity Champion

    can youp provide your measure code and share some sample data?  please show what you are expecting.

    • AndHan's avatar
      AndHan
      Frequent Visitor

      Here is what I'm expecting to see (the dark blue is what i'll end up visualizing):

       

      The two measures I'm trying to use looks like this:

       
      Timefordeling = CALCULATE(SUM(data[Data.personCount]))
       
      Number of Days =
      VAR a =
      FIRSTDATE ( 'Date'[Date] )
      VAR b =
      CALCULATE ( MAX ( 'Date'[Date] ) )
      RETURN
      DATEDIFF ( a, b+1, DAY )
  • AndHan's avatar
    AndHan
    Frequent Visitor

    And here's some sample data (csv):

    Data.personCount,Data.ts,Dato,Time
    16,19-05-2021 11:07,19. maj 2021,11
    24,17-05-2021 11:11,17. maj 2021,11
    19,18-05-2021 10:17,18. maj 2021,10
    17,18-05-2021 11:40,18. maj 2021,11
    14,17-05-2021 13:24,17. maj 2021,13
    13,17-05-2021 13:14,17. maj 2021,13
    12,19-05-2021 09:50,19. maj 2021,9
    11,17-05-2021 11:21,17. maj 2021,11

  • AndHan's avatar
    AndHan
    Frequent Visitor

    Anyone who has any suggestions on how to fix this? 🙂 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AndHan 

    I don't particularly understand the data you provided .What is the 'Date'[Date] ?

    Could you provide a sample that may help us to deal with your issue easier .

     

    Best Regards

    Community Support Team _ Ailsa Tao

     

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

    • AndHan's avatar
      AndHan
      Frequent Visitor

      Hi Anonymous

      The 'Date'[Date'] is from my Date table - it's used on a date picker in my report. 

      It returns the number of days selected, so I can use it to calculate the average pr. day.

       

      Hope it makes sense 🙂