Dataview datatype value as Number

Things I have tried

I am trying to create dynamic variables that I can use for some of my summary reports for the week. For example this allows me to get my average sleep per day for the week


And the following provides me with the average assessed from the week before


Now I simply want to do math to determine the difference like so:

=this.average_sleep - this.previous_week_average_sleep` 

Unfortunately I’m getting the following error:

Dataview (for inline query '=this.average_sleep - this.previous_week_average_sleep'): Operator '-' is not supported for 'string' and 'string

It appears that both variables are datatyped as string even though they were the output of the round() method which I would expect to output a number. This wouldn’t be such a big deal if there was a way to datatype my variable as I need it. I tried the number() but that did not work as expected since it is looking for numbers in the value, not datatyping.

Any ideas on how I can accomplish cascading, dynamic variables like I’m attempting here? I’ve also tried to look into the concepts of lambdas incase what was useful but I can’t find any examples that helps me understand how to do this. My next step is to look into DvJS

1 Like

About the query =this.average_sleep - this.previous_week_average_sleep I think the problem is: all yours “outputs” runs at same time. Because of this, you don’t have a “wait” to tell to the last query to wait for the output of the previous two and only then execute his own output.
As such, the query read the values of the two previous as simple strings.
Maybe JS has a way to solve this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.