Complex Query using IF function in Google Sheets [closed] - if-statement

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I'm trying to create a dynamic dashboard.
I've been able to create a query to filter for some of the information, but not all. What I'm trying to do is use the dashboard (the copy I shared is a slimmed-down version without charts) to select the collection period (this works), grade (this works) and IEP. I can get the IEP to query for accommodated or modified, but what I would like is to be able to select all IEPs that would combine the two (basically where that column is not null), and a query where is selected no IEPs (where the column is null). I'm struggling with putting this into the Query formula.
This formula works for all but the IEP query it's in cell A3 of 'Dataset' tab:
=QUERY({November!A5:X;February!A5:X;June!A5:X}, "where Col1= '" & A1 &"' " & if(H1="All",, "and Col8 = '" & H1 &"' ") & if(E1="",, "and Col5 = '" & E1 &"' ") & "and Col6 is not null order by Col9")
I've tried several other combinations (see bottom of 'Dataset' tab for what I've tried); it's a bit out of my scope, so any help would be appreciated!
Here is the sheet

try:
=QUERY({November!A5:X; February!A5:X; June!A5:X},
"where Col1 = '"&A1&"'"&
IF(H1="All",,"and Col8 = '"&H1&"'")&
IFS(E1="",,
E1="--",,
E1="None", "and Col5 is null",
E1="All IEPs", "and Col5 is not null",
E1<>"", "and Col5 = '"&E1&"'")&"
and Col6 is not null
order by Col9", 0)

Related

Filter elements in a table that contains text by chosing the words from another table [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed yesterday.
Improve this question
I have a table that contains a value and a text. I have another table containing several words.
Example:
Table 1:
1 the cat is in the house
2 the dog barks
3 the cat is on the roof
Table 2:
1 cat
2 dog
3 the
If i select cat in a filter linked to table 2, I need the results filtered as:
1 the cat is in the house
3 the cat is on the roof
If i select cat and dog in a filter linked to table 2, I need the results filtered as:
1 the cat is in the house
2 the dog barks
3 the cat is on the roof
Any ideas?
Thanks
I tried using filters but I confess I have no clue

Filter Data in Googlesheets

I have to face some problem about my Googlesheets Data. I want to filter my googlesheets data between two dates and also filter more conditions at the same time in same sheets. Below are given some sample data.
https://docs.google.com/spreadsheets/d/1h5PW52PoMUxXtrqEmfXSCWu_OKXVO8IwUbHqcqSPRzs/edit?usp=share_link
Basically, I want to filter data between two date & two more conditions at a same time in same sheets.
Please help me about this issues.
Thanks
I am trying to hard to solve this issues but I cann't solve this with myself. so if anyone solve this issues then please do this.
I'm very glad for all of you.
Thanks
use:
=IFERROR(QUERY('Raw Data'!A2:I,
"where 1=1 "&
IF(A7="",, " and B >= date '"&TEXT(A7, "e-m-d")&"'")&
IF(B7="",, " and B <= date '"&TEXT(B7, "e-m-d")&"'")&
IF(A10="",," and C contains '"&A10&"'")&
IF(A13="",," and D contains '"&A13&"'"), ), "no data found")
You can try:
=query('Raw Data'!A2:I,"Select * Where B >= date '"&text(A7,"YYYY-MM-DD")&"' AND B<= date '"&text(B7,"YYYY-MM-DD")&"'
AND C contains '"&A10&"' AND D contains '"&A13&"'")
Or, if you want to leave the dates empty:
=query('Raw Data'!A2:I,"Select * Where C contains '"&A10&"' AND D contains '"&A13&"'"&if(A7="",""," AND B >= date
'"&text(A7,"YYYY-MM-DD")&"'"&if(B7="",""," AND B<= date
'"&text(B7,"YYYY-MM-DD")&"'")))

SSRS Display Multi Select Parameters are part of report Output

I have a dropdown parameter that comes from a separate SQL procedure. It returns 3 strings like this ABC, XYZ, JKL. The parameter is mandatory, but the user can select 1 or 2 or all three of the values.
I need the report to display what the user selects.
For example if they select ABC and JKL I need the report to display "Shows Report: ABC, JKL.
I have the following code
="Shows Report. Hall: " & iif(isnothing(Parameters!hall.Value(0) = true),"", Parameters!hall.Value(0) & ", ") & iif(isnothing(Parameters!hall.Value(1) = true),"", Parameters!hall.Value(1) & ", ") & iif(isnothing(Parameters!hall.Value(2) = true),"", Parameters!hall.Value(2) ) & "."
However when the report runs I get an #error every time it runs.
The report does work if my code looks like this
="Shows Report. Hall: " & Parameters!hall.Value(0) & Parameters!hall.Value(1) & Parameters!hall.Value(2)
But this only works if I select all three parameters, not 1 or 2 of them. This also doesn't give me any formatting. I could add "," in between but I only want them to display if there are more then one value.
Please advise on any suggestions to fix this issue
Since it is a multi select parameter, why not just use this
="Shows Report. Hall: " + join(Parameters!hall.Value,", ")

Google Sheets Regexreplace for adding year to months

I have a dataset like this:
2019-01-02-03-04-05-06-07-08-09-10-11-12
2020-01-02-03-04-05-06-07-08-09-10-11-12
2021-01-02-03-04-05-06-07-08-09-10-11-12
2022-01-02-03-04-05-06-07-08-09-10-11-12
2023-01-02-03-04-05-06-07-08-09-10-11-12
2024-01-02-03-04-05-06-07-08-09-10-11-12
All of the content, for each row, in in one sing column.
I want to apply a regexreplace() to have a result like this:
2019-01,2019-02,2019-03,2019-04,2019-05,2019-06,2019-07,2019-08,2019-09,2019-10,2019-11,2019-12
2020-01,2020-02,2020-03,2020-04,2020-05,2020-06,2020-07,2020-08,2020-09,2020-10,2020-11,2020-12
2021-01,2021-02,2021-03,2021-04,2021-05,2021-06,2021-07,2021-08,2021-09,2021-10,2021-11,2021-12
2022-01,2022-02,2022-03,2022-04,2022-05,2022-06,2022-07,2022-08,2022-09,2022-10,2022-11,2022-12
2023-01,2023-02,2023-03,2023-04,2023-05,2023-06,2023-07,2023-08,2023-09,2023-10,2023-11,2023-12
2024-01,2024-02,2024-03,2024-04,2024-05,2024-06,2024-07,2024-08,2024-09,2024-10,2024-11,2024-12
That is basically replacing each "-" by the first 4 numbers in the corresponding row.
As I know those are the year in the first part and the months in number in the second part, I know I can used the following formula to have the expected result:
=regexreplace(A1,"^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})","$1-$2,$1-$3,$1-$4,$1-$5,$1-$6,$1-$7,$1-$8,$1-$9,$1-$10,$1-$11,$1-$12,$1-$13")
PS.: my data is in A1
But how to have something more dynamic, to replace several parts of the string with one portion of the same string?
try:
=ARRAYFORMULA(IFERROR(TEXT(INDEX(SPLIT(A1:A, "-"),,1)&"-"&
TRANSPOSE(QUERY(TRANSPOSE(SPLIT(A1:A, "-")), "offset 1", 0)), "yyyy-mm")))
then:
=ARRAYFORMULA(REGEXREPLACE(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(
TEXT(INDEX(SPLIT(A1:A, "-"),,1)&"-"&
TRANSPOSE(QUERY(TRANSPOSE(SPLIT(A1:A, "-")), "offset 1", 0)),
"yyyy-mm")&",")),,999^99)), ",$", ))
or without spaces:
=ARRAYFORMULA(REGEXREPLACE(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(
TEXT(INDEX(SPLIT(A1:A, "-"),,1)&"-"&
TRANSPOSE(QUERY(TRANSPOSE(SPLIT(A1:A, "-")), "offset 1", 0)),
"yyyy-mm")&",")),,999^99)), " |,$", ))
Would you really want REGEXREPLACE? Alternatively:
=ARRAYFORMULA(TEXTJOIN(",",TRUE,LEFT(A1,5)&SPLIT(MID(A1,6,LEN(A1)),"-")))
Using REGEXREPLACE, maybe something like:
=LEFT(A1,7)&REGEXREPLACE(A1,"(\d{4}-\d{2})?(-)",","&LEFT(A1,5))

DAX, Power BI - Concatenate strings

Does anyone know a DAX that could concatenate rows for the example in the image? I want to create a new measure that would englobe all countries together but summing up the repeated ones. BR + BRA would be Brasil.
Example here
I can add up the values for those countries in a DAX which would return numbers, but I am interested in strings specifically. Something like "if in country BR and BRA then Brasil, if in country CH and CHI then Chile".
Thanks!
Create a calculated column that unifies the countries.
all_countries =
SWITCH(
TRUE();
'panelCmd'[country] IN { "BR", "BRA" }; "Brasil";
'panelCmd'[country] IN { "CH", "CHI" }; "Chile";
'panelCmd'[country] IN { "ES", "ESP" }; "Spain";
<...et cetera...>
'panelCmd'[country]
)
Then you can use that column in your table instead of / in addition to country.
Reference on SWITCH(TRUE()...): The Diabolical Genius of “SWITCH TRUE”
Do you mean a measure that concatenate multiple strings into a single comma-delimited string?
If so, you may want to use CONCATENATEX iterator. More specifically, in Power BI Desktop, you can create a measure using the Quick Measure option, and then selecting the "concatenate..." option at the bottom. This will give you a code snippet that does that, and a good starting point.
use & to concatenate strings
Ex:
"String1 " & "String2" & " String3" => String1 String2 String3
Subheading = "for events that occured up to "& FORMAT(TODAY(),"DD") & "th " & FORMAT(TODAY(),"MMMM") & "
Result: for events that occured up to 16th December