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

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

Related

Regular Expressions - Snowflake [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 months ago.
Improve this question
enter image description hereI am trying to get text till the fourth "\n \n" from the below text. Can you please help me to write the snowflake expression for this issue.
Hello Jeffrey,\n \nWe have not heard from you yet. I hope all is well with you.\n \nChecking in to gather your Goosehead approved office location address, so we can add you to our database here at ERGOS. Once added here, we can schedule your laptop setup.\n \nGoosehead requires all agents to be onboarded by ERGOS so that we can provide IT support as well as get your laptop in our database. \n \nDo you have a laptop ready for setup?
so every thing up to the first \n \n can be fetched with regexp_substr via:
select
regexp_substr(column1, '.*\n \n') as match
from values
('Hello Jeffrey,\n \nWe have not heard from you yet. I hope all is well with you.\n \nChecking in to gather your Goosehead approved office location address, so we can add you to our database here at ERGOS. Once added here, we can schedule your laptop setup.\n \nGoosehead requires all agents to be onboarded by ERGOS so that we can provide IT support as well as get your laptop in our database. \n \nDo you have a laptop ready for setup?');
MATCH
Hello Jeffrey,
now, if we add a group around that ( ) and ask for 4 matches {4}, and swap to a smaller sample text, to make things less ugly for the output
select
regexp_substr(column1, '(.*\n \n){4}') as match
from values
('1111\n \n222222222222222\n \n3333333333333333\n \n44444444444444444\n \n55555555555555555555555');
gives:
MATCH
1111 222222222222222 3333333333333333 44444444444444444
if you are expecting the \n in the output:
then
select
column1,
regexp_substr(column1, '[^\\\\]+\\\\n \\\\n') as match
from values
('1111\\n \\n22222\\n \\n33333333\\n \\n4444444\\n \\n55555\\n \\66666\\n \\n7777');
shows how they need to be encoded in the SQL to output, and thus how to encode the match.
these matches greedy and gives:
COLUMN1
MATCH
1111\n \n22222\n \n33333333\n \n4444444\n \n55555\n \66666\n \n7777
1111\n \n
thus putting the grouping back in:
select
column1,
regexp_substr(column1, '([^\\\\]+\\\\n \\\\n){4}') as match
from values
('1111\\n \\n22222\\n \\n33333333\\n \\n4444444\\n \\n55555\\n \\66666\\n \\n7777');
COLUMN1
MATCH
1111\n \n22222\n \n33333333\n \n4444444\n \n55555\n \66666\n \n7777
1111\n \n22222\n \n33333333\n \n4444444\n \n
Picture to example for escaped new lines:

Survey completness problems in Google Sheets

I'm trying to have information about the completness in some survey results exported in to a Excel Format I'm using Google Sheets, as every survey there is questions and subquestions the subquestions have a conditional, Example: 4. How are you today? multiple choise answers: Good, Bad, Prefer not to say, so there we have 3 answer options if we click good there is a conditional and the subquestion will be: Why?. So in my survey there is 8 questions and question 4, 7 and 8 has conditional questions if someone answer "Yes". Now here is my problem to calculate the percentage of completness I used this relation: number of inputs in the survey/number of expected answers, But as I mentioned before the conditional affects this expected answers this Variable is dynamic depending on the answers from question 4, 7 and 8. So I would like to obtain this Variable for every case, if someone put information will have an ID if we have 20 persons doing the survey we will have 20 ID's. So for every record of answers the number will change depending on the inputs from Question 4, 7 and 8. I have prepared a document in Google sheets will the full aproach that I tried but is still hard to have it right I would like to have some help with this.
Link to the spreesheet
Here is an image about it:
if any parts of MAIN or SUB question make a whole MAIN/SUB question count as 1 use:
QUERY(TRANSPOSE(B2:F12),,9^9)
if all parts of MAIN/SUB question count as 1 use regular range:
AS2:BB12
change those ranges if I got them wrong:
=ARRAYFORMULA(IF(""={TRANSPOSE(TRIM({
QUERY(TRANSPOSE(B2:F12),,9^9); QUERY(TRANSPOSE(G2:X12),,9^9); QUERY(TRANSPOSE(Y2:AH12),,9^9);
QUERY(TRANSPOSE(AI2:AR12),,9^9); QUERY(TRANSPOSE(BC2:BD12),,9^9); QUERY(TRANSPOSE(BG2:BH12),,9^9);
QUERY(TRANSPOSE(BI2:BR12),,9^9); QUERY(TRANSPOSE(BS2:BU12),,9^9); QUERY(TRANSPOSE(BV2:BX12),,9^9);
QUERY(TRANSPOSE(BY2:CA12),,9^9); QUERY(TRANSPOSE(CB2:CD12),,9^9); QUERY(TRANSPOSE(CE2:CG12),,9^9);
QUERY(TRANSPOSE(CH2:CJ12),,9^9); QUERY(TRANSPOSE(CK2:CM12),,9^9); QUERY(TRANSPOSE(CN2:CP12),,9^9);
QUERY(TRANSPOSE(CQ2:CS12),,9^9); QUERY(TRANSPOSE(CT2:CV12),,9^9)})), AS2:BB12, BE2:BF12}, 0, 1))
to sum this up there are 17 queries and 2 regular ranges with 12 columns eg 17+12 = 29:
=ARRAYFORMULA(MMULT(IF(""={TRANSPOSE(TRIM({
QUERY(TRANSPOSE(B2:F12),,9^9); QUERY(TRANSPOSE(G2:X12),,9^9); QUERY(TRANSPOSE(Y2:AH12),,9^9);
QUERY(TRANSPOSE(AI2:AR12),,9^9); QUERY(TRANSPOSE(BC2:BD12),,9^9); QUERY(TRANSPOSE(BG2:BH12),,9^9);
QUERY(TRANSPOSE(BI2:BR12),,9^9); QUERY(TRANSPOSE(BS2:BU12),,9^9); QUERY(TRANSPOSE(BV2:BX12),,9^9);
QUERY(TRANSPOSE(BY2:CA12),,9^9); QUERY(TRANSPOSE(CB2:CD12),,9^9); QUERY(TRANSPOSE(CE2:CG12),,9^9);
QUERY(TRANSPOSE(CH2:CJ12),,9^9); QUERY(TRANSPOSE(CK2:CM12),,9^9); QUERY(TRANSPOSE(CN2:CP12),,9^9);
QUERY(TRANSPOSE(CQ2:CS12),,9^9); QUERY(TRANSPOSE(CT2:CV12),,9^9)})), AS2:BB12, BE2:BF12}, 0, 1),
SEQUENCE(29, 1, 1, 0)))
now to skip SUB question if empty we can do:
=ARRAYFORMULA(IF(""=TRANSPOSE(TRIM({
QUERY(TRANSPOSE(AS2:BB12),,9^9)})), 1, 0))
and then:
again, if you got more to skip add it like:
so the last step is to get the "% completeness":
=ARRAYFORMULA(MMULT(IF(""={TRANSPOSE(TRIM({
QUERY(TRANSPOSE(B2:F12),,9^9); QUERY(TRANSPOSE(G2:X12),,9^9); QUERY(TRANSPOSE(Y2:AH12),,9^9);
QUERY(TRANSPOSE(AI2:AR12),,9^9); QUERY(TRANSPOSE(BC2:BD12),,9^9); QUERY(TRANSPOSE(BG2:BH12),,9^9);
QUERY(TRANSPOSE(BI2:BR12),,9^9); QUERY(TRANSPOSE(BS2:BU12),,9^9); QUERY(TRANSPOSE(BV2:BX12),,9^9);
QUERY(TRANSPOSE(BY2:CA12),,9^9); QUERY(TRANSPOSE(CB2:CD12),,9^9); QUERY(TRANSPOSE(CE2:CG12),,9^9);
QUERY(TRANSPOSE(CH2:CJ12),,9^9); QUERY(TRANSPOSE(CK2:CM12),,9^9); QUERY(TRANSPOSE(CN2:CP12),,9^9);
QUERY(TRANSPOSE(CQ2:CS12),,9^9); QUERY(TRANSPOSE(CT2:CV12),,9^9)})), AS2:BB12, BE2:BF12}, 0, 1),
SEQUENCE(29, 1, 1, 0))/(29-IF(""=TRANSPOSE(TRIM({QUERY(TRANSPOSE(AS2:BB12),,9^9)})), 1, 0)))

Counting number of item types in a series in Python [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 2 years ago.
Improve this question
I am getting values from an api call and it returns one json value/key pair as a string at a time. I need to count how many times items with a certain prefix (which encodes the type of the item) occur:
Lets say I am getting 'abc123' as the 1st value
def getType(nodeName):
nodeCount = 0
if "abc" in nodeName:
count = count + 1
return "ABC", count
How do I retain this nodeCount value so that next time an item with prefix 'abc' comes in from the api call, the count can be incremented to 2.
Also, I need to create other counters to keep track of the count of other node types, such as 'xyz777'.
I tried to declare nodeCount as global variable but if I add "global count", that will defeat the purpose of retaining the count value for the next api call/iteration.
I am very new to python, so please let me know if there is any easy way.
Many Thanks!
You may use a collections.Counter like this:
from collections import Counter
def getType(counter, nodeName):
nodetype= nodeName.rstrip('0123456789')
counter[nodetype] += 1
return nodetype.upper(), counter[nodetype]
c= Counter()
for n in ['abc123', 'def789', 'ghijk11', 'def99', 'abc444']:
nodetype, nodecount = getType(counter= c, nodeName= n)
print('type {} \t: {}'.format(nodetype, nodecount))
print('summary:')
print(c)

Trying to find a way to list all friday dates between 2 dates in powershell [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How to identify a list of dates with a specific day of the week between 2 dates in Powershell
No problem, it's fairly straightforward:
$date = [datetime]::parseexact('07-Feb-20', 'dd-MMM-yy', $null)
$date2 = [datetime]::parseexact('28-Feb-20', 'dd-MMM-yy', $null)
$fridays = 1..($date2 - $date).Days | % {$date.AddDays($_)} | ? {$_.DayOfWeek -eq 'Friday'}
Just make sure you put your dates in correctly! There's likely a more succinct way to do it.
Every PowerShell [datetime] object contains a .DayOfWeek parameter which will tell you the day of the week. You can interate through the date items with another [datetime] feature, the .AddDays() method. So something like this:
$StartDate = [datetime]'datehere'
$EndDate = [datetime]'datehere'
$ThisDate = $StartDate
$AllFridays = #()
While ($ThisDate -le $EndDate)
{
If ($ThisDate.DayOfWeek -eq 'Friday') { $AllFridays += $ThisDate }
$ThisDate.AddDays(1)
}
This was just a first crack. Obviously, you could find the first friday, and then add days 7 at a time until you were past the End date, but I leave that optimization as an exercise for the reader. :)

Complex Query using IF function in Google Sheets [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 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)