Search code examples
looker-studio

How to remove incorrectly formatted text data in Google Data Studio?


I am exstracting Text format data from Firebase and I want to show only correctly formatted data in LookerStudio.

Now the text data looks like this,

No. Sample_Date
1 AAA 1/2(M)
2 AAA 1/17(T)
3 AAA 12/7(W)
4 AAA M 21/2
5 AAA W 23/2
6 AAA T, 21/2
7 AAA W 21.2.
8 AAA M 27-2
9 AAA 2.21. (T)
10 AAA 2/21T

Data such as No.1-3 "AAA MM/DD(D)" is the correct format. Other format such as No.4-10 is incorrect formtat, and I want to remove them from the report.

What I tried:

I have tried to extract correct data that contains "/" and "()" using RegEx, but this cannot extract "()" correctly.

CASE
 WHEN REGEXP_CONTAINS(Sample_Date, "AAA") AND WHEN REGEXP_CONTAINS(Sample_Date, "/") AND WHEN REGEXP_CONTAINS(Sample_Date, "(.)") THEN "Correct Data"
ELSE "Other"
END

Here is Publicly editable sample data of Looker Studio.

Any advice would be helpful.


Solution

  • Added regex expression to your dash here:

    REGEXP_MATCH(Sample_Date,"[A-Z]{3} \\d+/\\d+\\(.\\)")
    

    enter image description here