I want to extract text before the last space from column A and add it to column B.
Example of input:
Chicago A12
New York GE8
United States of America AB8
Wanted output:
Chicago
New York
United States of America
ColumnB =
VAR string_length = LEN('Data'[ColumnA])
RETURN
TRIM(
LEFT(
SUBSTITUTE('Data'[ColumnA];" "; REPT(" "; string_length));string_length)
)
This does only work if I have one word before the space.
Output:
Chicago
New
United
Assuming you always have last 3 characters behind your Inpurt such as A12, GED or so on
Create New Field and add below expression to it.
Note: Assuming you are not having City column as Null or empty, else you will have to add one more condition of if
Expected Result = LEFT('Table'[City];LEN('Table'[City])-3)
Related
I am trying to group a table by a column, so the resulted table have unique values in that column, and also returns all the unique values from another column that belonged to the grouped column:
Source:
Country = USA
Cities =
New York
Boston
Chicago
Houston
Transform: group by [Country] column, and return unqiue values from [Cities] and coma seperated:
Country = USA
Cities = New York,Boston,Chicago,Houston
thanks a lot
You can simply use CONCATENATEX in a measure
Measure = CONCATENATEX(VALUES('Table'[Cities]),'Table'[Cities],",")
I get the filter has mismatched range error when I insert this: Data!N3:N <> "", "No Market")
Formula in Google Sheets
=FILTER(Data!B3:N,
Data!C3:C>=B1,
Data!C3:C<=D1,
Data!N3:N <> "", "No Market")
I'm trying to replace the blank values in Column N with the text "No Market"
Sample Table
Column B
Column N
03/07/2021
New York
03/07/2021
03/07/2021
Seattle
04/04/2021
04/04/2021
Boston
This formula also worked, but it excludes the blank values and I would like to include them.
=FILTER(Data!B3:N,
Data!C3:C>=B1,
Data!C3:C<=D1,
Data!N3:N <> "")
Column B
Column N
03/07/2021
New York
03/07/2021
Seattle
04/04/2021
Boston
Expected Results:replaces blank values with "No Market"
Column B
Column N
03/07/2021
New York
03/07/2021
No Market
03/07/2021
Seattle
04/04/2021
No Market
04/04/2021
Boston
I appreciate your help, thanks in advance!
Try below formula-
=ArrayFormula({A2:A6,IF(B2:B6="","No Market",B2:B6)})
It's difficult to write full formulas without access to any actual data, but this should work for you:
=ArrayFormula(IFERROR(FILTER({Data!B3:M, IF(Data!N3:N="", "No Market", Data!N3:N)}, Data!C3:C<>"", Data!C3:C>=B1, Data!C3:C<=D1)))
If it does not work as expected, consider sharing a link to the spreadsheet.
I know the title is a horrible description, sorry.
Basically I have a sheet with results from basketball games. So in column A I have the home team. In column B I have the away team. In column C the home team's points. In column D the away team's points. There's about 500 rows worth of data at the minute.
What I want to do is the following:
Say I want to get the average points scored by the New York Knicks in their last 5 games. The most recent games are at the bottom of the sheet, and the first/oldest ones at the top of the sheet.
So across the bottom/last 5 instances of "New York Knicks" in column A and B, I want the average of the results of C (if New York Knicks is in column A) and D (if in column B).
I know how to do this if I would want just the last 5 home games for instance (so in that instance I basically query the bottom 5 results of column C in the last 5 occurrences of column A being New York Knicks). I don't know how to do it when I am looking for when New York Knicks occurs in either column A or B, and then have to get the averages from column C or D.
Can anyone help?
this will transform your 4 columns into 2 columns:
=ARRAYFORMULA(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(A2:B<>"", "♠"&A2:B&"♦"&C2:D, )),,999^99)),,999^99), "♠")), "♦"))
and average score of the last 5 games:
=ARRAYFORMULA(AVERAGE(QUERY(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(A2:B<>"", "♠"&A2:B&"♦"&C2:D, )),,999^99)),,999^99), "♠")), "♦"),
"select Col2
where lower(Col1) contains 'new york knicks'
offset "&COUNTIF(A2:B, "new york knicks")-5)))
I'm relatively new to Power BI and want to generate a new one based on a column. The contents of the new column should be based on the first value of another column. For example:
ColumnA NewColumn
1123 Argentinia
5644 Brazil
5555 Brazil
3334 Denmark
1124 Argentinia
As you can see, the first value of the number decides which country will be added to the new column.
In SQL I know that I can use something like this:
`select * from table where column LIKE '%[2]`%'
and so on but is this possible with Power BI? Thanks a lot.
Edit:
My additional list looks like this:
ID Country
1 Argentina
2 Swiss
3 Denmark
4 Norway
5 Brazil
and so on...
I thougt I could use somethin like this:
NewColumn = IF('table'[ColumnA] = "%[1]`%"
THEN "Argentinia"
ELSE if IF('table'[ColumnA] = "%[2]`%
THEN Swiss
ELSE "No Country")
Add your Number / Country List to a new table. Let's assume you call it Countries.
Now you can add a column to your original table (let's assume you've called that one Fact Table), using something like:
Country =
LOOKUPVALUE (
Countries[Country],
Countries[ID],
VALUE ( LEFT ( 'Fact Table'[ColumnA], 1 ) )
)
See https://pwrbi.com/so_56391689/ for worked example.
Okay, I've now also found a solution:
NewColumn = SWITCH(TRUE();
LEFT(table[ColumnA]; 1) in {"1"}; "Argentina";
LEFT(table[ColumnA]; 1) in {"2"}; "Swiss";
LEFT(table[ColumnA]; 1) in {"3"}; "Denmark";
LEFT(table[ColumnA]; 1) in {"4"}; "Norway";
LEFT(table[ColumnA]; 1) in {"5"}; "Brazil"
)
Works very well :)
I have a column with values like below in my power BI table:
14 Madrid
1409 Moscow - TC
1510 Millan - FGHM
1405 London - XXXXX- YYYYY
You will observe that the first string is a numeric value followed by a space. The second string is a city and that's what i want to extract as a new column. Am not interested in what ever comes after the city.
Any one have an idea of which DAX formula i can use to achieve this?
The expected values in my new calculated column would be as below:
Madrid
Moscow
Millan
London
Assuming that if anything follows the city name there is a dash included, you could try a calculated column like this:
City =
VAR FirstSpace = FIND(" ", Table[Column1])
VAR Dash = FIND("-", Table[Column1], 1, LEN(Table[Column1]) + 2)
RETURN MID(Table[Column1], FirstSpace, Dash - FirstSpace - 1)