Forum Discussion

nosaj03's avatar
nosaj03
Helper II
6 years ago
Solved

Creating a Measure based on Previous day

Hello all!

 

I have a Sales table of employees by day by item category and total time on sale

 

I want to create a measure that shows the averge time for sales for by employee for the previous day based on current day.

 

Example

DateEmployee GroupItem groupSalesTime 
5/19/2020JoeTechIOS3819
5/19/2020JoeTechAndroid112247
5/19/2020JoeTechWindows3111056
5/19/2020JoeTechGaming1176
5/18/2020JoeTechIOS4919
5/18/2020JoeTechAndroid15254
5/18/2020JoeTechWindows2612001
5/18/2020JoeTechGaming14201

 

I want to find out the average time for Joe on 5/18 so the formula is sum(Time)/sum(sales)

 

I've been using the following formula

Calculate(divide(sum(Time),sum(Sales),0),filter(date = now()-1)) and it returns nothing. 

 

Other times its gives me the "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value" or the Divide by Zero error. 

 

I'm stuck here. Any help would be greatly appreciated.

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    nosaj03 

     

    You should use Today() instead of Now(), because Now()-1 return current time-1 second, not previous day.  And for the sample you provided, you can test it by replace Today() with Date(2020,5,19) to check the average of 5/18

     

    Measure Calculate(divide(sum([Time ]),sum([Sales]),0),filter('Table',[Date]= TODAY()-1))

     

     

    Paul Zheng _ Community Support Team
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

7 Replies