Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 months ago.
Improve this question
Not sure if I correctly named (subject) this issue.
My code: ="Discount "$M4
It doesn't work because I do not close the brackets " after $M4. But when I write $M4" it reopens another input for text and needs to close the bracket with another ".
So I tried """, doesn't work either. The third bracket reopens an input too...
Anyone knows how to close a text input with a bracket in this condition, without reopening one? Thanks.
Reproducible sample:
I do not think you need the full tables as this is only a typo issue within the formula, if you feel you do please ask me in the comments and I'll it.
Full formula:
=IF($R$1="No",INDEX(VLOOKUP($M$2, QUERY({'Exchange Fees'!$B$2:$B, 'Exchange Fees'!$D$2:$D,
FILTER('Exchange Fees'!$A$2:$G, 'Exchange Fees'!$A$1:$G$1=$M4)},
"select Col2,Col3 where Col1 = '"&N$2&"'", ), 2, 1)),INDEX(VLOOKUP($R$1, QUERY({'Exchange Fees'!$B$2:$B, 'Exchange Fees'!$J$2:$J, 'Exchange Fees'!$L$2:$L,
FILTER('Exchange Fees'!$A$2:$L, 'Exchange Fees'!$A$1:$L$1="Discount "&$M4)},
"select Col2,Col3,Col4 where Col1 = '"&N$2&"'", ), 2, 0)))")))))"""
try:
'Exchange Fees'!$A$1:$L$1="Discount "&$M4
update:
=IF($R$1="No",INDEX(VLOOKUP($M$2, QUERY({'Exchange Fees'!$B$2:$B, 'Exchange Fees'!$D$2:$D,
FILTER('Exchange Fees'!$A$2:$G, 'Exchange Fees'!$A$1:$G$1=$M4)},
"select Col2,Col3 where Col1 = '"&N$2&"'", ), 2, 1)),INDEX(VLOOKUP($R$1, QUERY({'Exchange Fees'!$B$2:$B, 'Exchange Fees'!$J$2:$J, 'Exchange Fees'!$L$2:$L,
FILTER('Exchange Fees'!$A$2:$L, 'Exchange Fees'!$A$1:$L$1="Discount "&$M4)},
"select Col2,Col3,Col4 where Col1 = '"&N$2&"'", ), 3, 0)))
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 months ago.
Improve this question
how can i change the background color based on text in power bi as per attach. For example, critical is red, reorder is yellow, ideal is green and etc.
Use this calculated column
Color =
SWITCH(
TRUE(),
'Table'[Status] = "Critical", "#FF0000",
'Table'[Status] = "Ideal", "#008000"
)
Then you go to formatting of cell elements, Font color, based on Field value:
And the result will look like this:
You can use conditional formatting for background color under 'Cell elements'.
Format/Cell elements/Background color/On
Background Color:
Background Color = SWITCH(TRUE(),
Table[Status] = "Critical", "#FF0000",
Table[Status] = "Reorder", "#FFFF00",
Table[Status] = "Ideal", "#00FF00",
Table[Status] = "Overflow", "#0000FF"
)
I've looked up every solution to this question and tried them all with no luck.
Im importing coordinates from another page and determining if they're between a range using the =if(and() function. But it seems like the and() will only accept 3 and() statements max. And some of the functions don't even register in the functions. I cant figure out why.
All cells are formatted as numbers
tried various combinations
Feel free to play with the function. I've been working on it for 3 days and still can't find a solution. Can anyone help?
https://docs.google.com/spreadsheets/d/1OZSDju3hRyGyRfFhHJT2PLQ3DBvcfOAT1ZvNxB-J0DQ/edit?usp=sharing
Take a look at the green higlighted rows. They all fall within the Green highlights range but nothing.,,
try:
=ARRAYFORMULA(IF(
IFNA(VLOOKUP(A2:A*1, SORT(QUERY(SPLIT(FLATTEN(IF(F2:G="",,F2:G&"♦"&E2:E)), "♦"),
"where Col2 is not null", 0)), 2, 1))=
IFNA(VLOOKUP(B2:B*1, SORT(QUERY(SPLIT(FLATTEN(IF(H2:I="",,H2:I&"♦"&E2:E)), "♦"),
"where Col2 is not null", 0)), 2, 1)),
IFNA(VLOOKUP(A2:A*1, SORT(QUERY(SPLIT(FLATTEN(IF(F2:G="",,F2:G&"♦"&E2:E)), "♦"),
"where Col2 is not null", 0)), 2, 1)), ))
!! however
in case of possible overlaps you will need to use this formula and drag down:
=ARRAYFORMULA(TEXTJOIN(", ", 1,
IF((A2*1>=F$2:F)*(A2*1<=G$2:G)*(B2*1>=H$2:H)*(B2*1<=I$2:I), E$2:E, )))
your importrange should be:
=ARRAYFORMULA(REGEXREPLACE(""&QUERY(
IMPORTRANGE("1ol7DTYZcwZVZk6WhfCLQ1JBt3_3QIEXEC5TkfEerCMw", "CheckinForm!I2:J30"),
"where not Col1 = '#ERROR!' and Col1 is not null", 0), "^: ", )*1)
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 7 years ago.
Improve this question
I have been trying to set up REGEX extraction process for the following to no avail.
I have a set of date values in the formats to follow. I need to be able to extract these as unique individual dates.
If there is a single value, it is a standard simple format of mm/dd/yyyy. That one is easy.
If there are more than one date value, then it can be in a format as follows:
Feb 5, 12, 19, 26, Mar 4, 11 2016
I need to turn these into 02/05/2016, 02/12/2016, etc.
Eventually I will be inserting these dates into a database.
Am I going about this in the wrong way? Thanks for advice.
This will be complete spaghetti if you try to do it with one regex:
You will have to hardcode the names of the months and the corresponding numbers somewhere.
The year doesn't follow after the list of days of the month, rather after the list of all month names - month days this year.
However with a little help from a normal programming language you can still get a short and regex-centric solution. Here is a small Ruby snippet to show the general idea:
# this is the input
dates = "Feb 5, 12, 19, 26, Mar 4, 11 2016, Jul 5, 7, 19, 26, May 4, 11 2017"
# a hash with month name => month number
MONTHS = {
'Jan' => '01',
'Feb' => '02',
'Mar' => '03',
'Apr' => '04',
'May' => '05',
'Jun' => '06',
'Jul' => '07',
'Aug' => '08',
'Sep' => '09',
'Oct' => '10',
'Nov' => '11',
'Dec' => '12',
}
# match and extract three things:
# month - the first found month name (three letters)
# days - list of days separated by commas and spaces for this month
# for example 5, 12, 19, 26,
# year - the first found year (four digits)
# ,? is because we don't have , after the last day of the year
while dates =~ /(\w{3}) ((?:\d\d?,? )+).*?(\d{4})/
month, days, year = $1, $2, $3
# to each day collate a date in the wanted format
# MONTHS[month] gets the month number from the hash above
# sprintf simply makes sure that one digit days will have a leading 0
dates_this_month = days.split(/,? /).map do |day|
"#{MONTHS[month]}/#{sprintf('%02d', day)}/#{year}"
end.join ', '
# substitute the dates for this month with the new format
dates.sub! "#{month} #{days}", "#{dates_this_month}, "
end
# remove leftover years
dates.gsub! /, \d{4}/, ''
Now dates is in the desired format.
Assuming that there are no deviations or anomalies in the data that you're RegExing, the following RegEx can be applied with case-sensitivity set and allow you to access the information you need. With RegExs, it's important to "know your data" because this variable can greatly alter the construction of a RegEx -- the balance between specificity and clarity is important since RegExs can easily become unwieldy and cryptic.
Save the months as: ([A-Z][a-z][a-z]) // this can be your $1 variable (useful later)
Save the day values as: \s*(?:([0-9]?[0-9]),\s)* // $2 variable should work for access to this list of values
Save the year values as: ([0-9]{4,4}) // $3 variable should work for accessing these values NOTE: this only works for #### formatted dates by design although it can be altered to handle different formats; I'm just going off of the example you provided
Stringing it all together you get: (?:([A-Z][a-z][a-z])\s*(?:([0-9]?[0-9]),\s)*)+([0-9]{4,4})
You can then construct objects with these values so that you don't end up with a bunch of chaotic data. Let me know if I addressed you problem properly. If there's something that I missed or some additional functionality that you forgot to mention, I will be happy to assist.
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 8 years ago.
Improve this question
perlI have tab delimited text file with 3 columns like following
Name Description Ontology
dda1 box1_homodomain gn=box1 os=homo C:Cell;C:surface;F:binding;P:toy
dda2 sox2_plurinet gn=plu os=mouse C:Organ;F:transport;P:carrier;P:avi
dd13 klf4_iPSC gn=klf os=Bos C:Cell;F:tiad;P:abs;P:digestion
Now I would like to split the values (gn=xxx and os=xxx) in column Description and values in Ontology column(C:xxx;F=xxx;P=xxx;) into seperate columns like following:
Name Description gn os C F P
dda1 box1_homodomain box1 homo Cell;surface binding toy
dda2 sox2_plurinet plu mouse Organ; transport carrier;avi
dd13 klf4_iPSC klf Bos Cell; tiad abs;digestion
I want this has to export as tab delim file or excel file.I would be really great if someone can guide how can I achieve that in perl. Please help me.
Thanks in advance
I saw perl question after 5 years of my Java. I was excited and i want to do this exercise. Now, that i remember things i did and pasted the code below. Just enrich the same code for last column 'Ontology' with regexp and same hash concept you are done. You can do multiple ways in perl. It could be more code. But, i remember below way.
#!/usr/bin/perl
use Data::Dumper;
my %output;
open(IN, "stack.txt");
while(<IN>) {
my #nameColumns, #descriptionColumns;
if ($_ =~ /Name/) {
$ouput{'Name'} = #nameColumns;
$ouput{'Description'} = #descriptionColumns;
next;
}
my ($group1, $group2, $group3, $group4, $group5, $group6, $group7) = ($_ =~ m/(\w+)\s+(\w+)\s+(\w+)\=(\w+)\s+(\w+)\=(\w+)\s+(.*)/gi);
# Column 1
#nameColumns = #{$output{'Name'}};
push(#nameColumns, $group1);
$output{'Name'} = [#nameColumns];
# Column 2
#print "$group2, $group3, $group4, $group5, $group6, $group7";
#descriptionColumns = #{$output{'Description'}};
push(#descriptionColumns, $group2);
$output{'Description'} = [#descriptionColumns];
# column 3
#column3 = #{$output{$group3}};
push(#column3, $group4);
$output{$group3} = [#column3];
# column 4
#column4 = #{$output{$group5}};
push(#column4, $group6);
$output{$group5} = [#column4];
#Column ...
}
close(IN);
print Dumper(\%output);
$VAR1 = {
'gn' => [
'box1',
'plu',
'klf'
],
'os' => [
'homo',
'mouse',
'Bos'
],
'Name' => [
'dda1',
'dda2',
'dd13'
],
'Description' => [
'box1_homodomain',
'sox2_plurinet',
'klf4_iPSC'
]
};
Note : Output above. If you still didn't figure out, how to finish this program let me know to spend more time
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a small problem I'd like to know the best way to store eyes or hairs colors with django.
This is what I did before asking myself what the best way :)
HAIR_COLORS = (
('1', 'braun'),
('2', 'blond'),
('3', 'red'))
hair_color = models.IntegerField(max_length=1, choices=HAIR_COLORS)
Is it a good choice ? Do I have to replace The integerField() by a CharField() with choices like:`
HAIR_COLORS = (
('braun', 'braun'),
('blond', 'blond'),
('red', 'red'))
In fact I'm not satified, what is your favorite way to implement ?
Thank you.
Best way is:
BROWN = 10
BLOND = 20
RED = 30
HAIR_COLORS = (
(BROWN, 'braun'),
(BLOND, 'blond'),
(RED, 'red'))
hair_color = models.IntegerField(max_length=2, choices=HAIR_COLORS)
The reason for that is:
When you use such numbers you always can insert additional color at any place in choices.
Use constants not directly the numbers because in the code when you check or update is far better and explicit to make
if obj.hair_color == BROWN instead if obj.hair_color == 10
or
obj.hair_color = BROWN compared to obj.hair_color = 10
Also better naming convention is recommended for example: prefix for the constants like EYES_BROWN and suffix for the choices like HAIR_COLORS_CHOICES. And these statements should reside outside the model for easier import in other parts in the project.
For those types of definitions, i create a global_defs.py file
global_defs.py:
HAIR_COLOR_BROWN = 1
HAIR_COLOR_BLACK = 2
...
In models:
import global_defs as defs
...
class person(models.Model):
...
color = models.IntegerField(default=defs.HAIR_COLOR_BROWN)
In the end you refer to those values by name in all your code, so it's nicely speaking. However in the Database you cannot directly see what each value means.