# Dataview datatype value as Number

**URL:** <https://forum.obsidian.md/t/dataview-datatype-value-as-number/27190>\
**Category:** Help\
**Tags:** dataview\
**Created:** [November 16, 2021, 5:50am UTC](https://forum.obsidian.md/t/dataview-datatype-value-as-number/27190 "2021-11-16T05:50:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xtremefaith](https://forum.obsidian.md/user_avatar/forum.obsidian.md/xtremefaith/32/19187_2.png) [@Xtremefaith](https://forum.obsidian.md/u/Xtremefaith)\
**Post date:** [November 16, 2021, 5:50am UTC](https://forum.obsidian.md/t/dataview-datatype-value-as-number/27190/1 "2021-11-16T05:50:54Z")

</div>

### 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

```auto
average_sleep::`=round(sum([[2021-W46]].file.inlinks.sleep_time)/7,2)

```

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

```auto
previous_week_average_sleep_quality::`=[[2021-W45]].average_sleep_quality

```

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

```auto
=this.average_sleep - this.previous_week_average_sleep` 

```

Unfortunately I’m getting the following error:

```auto
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

---

<div class="post-metadata">

**Author:** ![mnvwvnm](https://forum.obsidian.md/user_avatar/forum.obsidian.md/mnvwvnm/32/9766_2.png) [@mnvwvnm](https://forum.obsidian.md/u/mnvwvnm)\
**Post date:** [November 16, 2021, 3:58pm UTC](https://forum.obsidian.md/t/dataview-datatype-value-as-number/27190/2 "2021-11-16T15:58:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [December 16, 2021, 3:58pm UTC](https://forum.obsidian.md/t/dataview-datatype-value-as-number/27190/3 "2021-12-16T15:58:39Z")

</div>

Closed on December 16, 2021, 3:58pm UTC

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