'How can I convert a date field to number in Google Data Studio?
In Google Data Studio I'm searching for a formula to transform a date field into a number field.
I have been trying several options like these but they don't work.
CAST(Date_field as NUMBER)
Invalid formula - Cannot cast from DATE to DOUBLE
Date_field+0
Invalid formula - Operator "+" doesn't support DATE + NUMBER. Operator "+" supports NUMBER + NUMBER.
datevalue() or value() also don't exist.
Precision: I'm looking for a solution without changing the original date field in the data source or the connection. Only with a formula.
The expected result is a continuous series of integer numbers like this (the zero reference point doesn't matter, as long as 2 consecutive days are incremented by 1.)
| Date_field | Expected_output |
|---|---|
| 23 Feb 2022 | 44,615 |
| 22 Feb 2022 | 44,614 |
| 21 Feb 2022 | 44,613 |
| 2 Jan 2022 | 44,563 |
| 1 Jan 2022 | 44,562 |
| 31 Dec 2021 | 44,561 |
| 30 Dec 2021 | 44,560 |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
