Table transformation Google Sheets - if-statement

I'm trying to convert such table:
into such table:
First table is very big, and is being changed automatically by another user.
I'd like to use Google Sheets' query function. Any idea how?
Thanks in advance!

use:
=INDEX(QUERY(SPLIT(FLATTEN(B1:D1&"×"&A2:A&"×"&B2:D), "×"),
"where Col2 is not null"))

Related

How to use Query functions to count values from rows?

I would like to ask help to use Query functions to count values from rows?
I knew how to use =COUNTA() function to generate same results. Since my data is huge, I prefer to use Query function to keep my data flexible. Thank you for helping.
https://docs.google.com/spreadsheets/d/1dYrf4b1G7UouSY4XczqAClK3PhFWUkMVHJDftBRS65c/edit?usp=sharing
try:
=INDEX(QUERY(FLATTEN(IF(B2:F10="",,A2:A10)),
"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1)''"))

Filter data (Not In) based on condition within two data sets in Google sheet

Have employee data set with status active and relieved. And the second data set has the time they have reported to the office. Trying to achieve the names of employee who are absent for the day using one formula. I have attached the images for easy understanding. Please find the sheet wherein I have created sample data and formula which I have used. Trying to achieve it using one array formula or query
https://docs.google.com/spreadsheets/d/1Dj7agceCBS_aCm2GVm4EQHqS8_wQYifoKLMcA0fv4fM/edit?usp=sharing
Have achieved it using Filter and Match
{"Absent For the Day";FILTER((query(importrange("1Dj7agceCBS_aCm2GVm4EQHqS8_wQYifoKLMcA0fv4fM","empdata!A2:B30"),"select Col1 where Col2='Active'")),ISERROR(MATCH((query(importrange("1Dj7agceCBS_aCm2GVm4EQHqS8_wQYifoKLMcA0fv4fM","empdata!A2:B30"),"select Col1 where Col2='Active'")),A2:A20,0)))}
try:
=ARRAYFORMULA({"Absent For the Day", "";
SPLIT(FILTER(empdata!A2:A, empdata!B2:B="active",
NOT(REGEXMATCH(empdata!A2:A, TEXTJOIN("|", 1, A2:A))))&"♦Absent", "♦")})
try:
=ARRAYFORMULA({"Absent For the Day", "";
SPLIT(QUERY(IMPORTRANGE("1Dj7agceCBS_aCm2GVm4EQHqS8_wQYifoKLMcA0fv4fM", "empdata!A2:B"),
"select Col1
where lower(Col2) = 'active'
and not Col1 matches '"&TEXTJOIN("|", 1, A2:A)&"'", 0)&"♦Absent", "♦")})

Transpose cell data into separate rows

I wanted to see if there was a formula or something that I could do to get something like this accomplished in Google Sheets.
Table 1 is the input I am getting
Table 2 is the output I want to generate on a separate sheet
I am trying to use output I get from a Google form into a Google sheet and create a CSV to import into Google Groups.
=ARRAYFORMULA(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(IFERROR(SPLIT(B2:B, ","))<>"", "♦"&SPLIT(B2:B, ",")&
REGEXEXTRACT(A2:A, "(#.*)")&"♣"&A2:A, )),,999^99)),,999^99), "♦")), "♣")))

Power BI extract filename from path in table

In Power BI does anyone have any idea how I can extract a filename from a path in a table column without using SQL? DAX does not seem to have reverse searches. Also please note that some file names do not have paths.
In SQL I could achieve this with the following:
CASE
WHEN #FullPath = 'TRUE' OR CHARINDEX('\', dbo.Usage.App) = 0 THEN
UPPER(dbo.Usage.App)
ELSE
UPPER (RIGHT(dbo.Usage.App, CHARINDEX('\', REVERSE(dbo.Usage.App)) -1))
END
AS AppName
Assuming your fullpath is in Column1, I believe this DAX based solution would work:
Create a new column with...
=RIGHT([Column1],LEN([Column1])-SEARCH("#",SUBSTITUTE([Column1],"\","#",LEN([Column1])-LEN(SUBSTITUTE([Column1],"\","")))))
I found this solution here.
Here's a screenclip that might help too:
Be sure to replace Column1 with the name of your column.
You can try this:
if(SEARCH("\", [App],1,-1)=-1, [App], RIGHT([App],LEN([App])-SEARCH("#",SUBSTITUTE([App],"\","#",LEN([App])-LEN(SUBSTITUTE([App],"\",""))))))

SELECT Column1 FROM tablename in Django

Okay I know this is really stupid.But how to i write SELECT Column1 FROM tablename
I know i can use Court.objects.all()[0] to get just one row.But how do I get one column only(the whole column values).Am I missing something?
Also in Court.objects.all()[0] isn't it first retrieved and then spliced.So isn't it kinda inefficient.
Court.objects.values_list('column_name', flat=True)
And if you write Court.objects.all()[0] only one row is retireved.
Court.objects.only('column_name')