Search code examples
regexlooker-studiore2

How I extract number from text in Google Data Studio?


I tried this but it's still showing null as you can see in the screen. Please help to solve this.

REGEXP_EXTRACT(X,"[0-9]*[0-9]")

Extract number from text


Solution

  • It can be achieved using the Calculated Field below which uses the REGEXP_EXTRACT function to extract the numbers and the CAST function to ensure that it's a Number field:

    CAST(REGEXP_EXTRACT(Attività, "(\\d+)") AS NUMBER )
    

    Google Data Studio Report and GIF to elaborate: