Check multiple columns and return to cell from other multiple columns - if-statement

So I've added a SS of what i'm trying to do.
I need to check if Value(Col B) is Value3 and Cat (Col C) is Cat4
than fill corresponding cell (K5) under Cat/Vol table with Result +
(Number). In this case K5 should be filled with Result1(13).
Whenever a new row added under Incoming Data Table, Cat/Vol table
should also be updated with the new Result + Number. So incoming data table is dynamic and will be updated with rows only.
For instance if B11 is Value2 and C11 is Cat5 than "I4" should be
updated with the new Result and Number.
I tried placing IF and IF AND + REGEXTRACT formulas under each cell of Cat/Vol Table without anyluck. Thanks in advance.

My answer is not the most elegant but it was quick.
The heart of this formula is vlookup that searches using keys of 2 merged cells:
=ifna(ArrayFormula(vlookup($G2&H$1,{arrayformula($B$2:$B&$C$2:$C),$D$2:$E},2,false))
&"("&ArrayFormula(vlookup($G2&H$1,{arrayformula($B$2:$B&$C$2:$C),$D$2:$E},3,false))&")")
It's then copied to all the cells of new table.
Working solution is here:
https://docs.google.com/spreadsheets/d/1qbIg9nNfaOwQtSbk8R8-NkT_6cOy3AKr3Xafm72SsNI/copy

Related

Power Query: How do I add a specific List/Vector as a Column

I have a simple problem. Let's assume I have the following
Now I want to add a specific vector or list for example (1,2,2,1) as an additional column and it should look like
When I add "Custom Column", how do I have to enter this list that it creates exactly this column?
It should not be a index column or a calculated column because I want to specify the values depending on another column manually. It seems like it is a very simple task, but I couldn't find any solutions yet! (I feel very stupid xD)
pls help
Thank you!
let Source = #table({"Column1"},{{"A"},{"B"},{"C"},{"D"}}),
Add = {{1,2,2,1}},
part1=Table.ToColumns(Source) & Add,
part2= Table.FromColumns(part1,Table.ColumnNames(Source)&{"Column2"})
in part2
or perhaps, if grabbing column from another table
let Source = #table({"Column1"},{{"A"},{"B"},{"C"},{"D"}}),
part1=Table.ToColumns(Source) & Table.ToColumns(Table.SelectColumns(SomeOtherTable,"Column9")),
part2 = Table.FromColumns(part1,Table.ColumnNames(Source)&{"Column2"})
in part2
Copy your Column1
Open the Enter Data / Create Table UI and paste Column1
Add your specific vector as Column2 and save the new table
Merge the new table into your original table using both Column1
Note that Column1 has to be a key column (unique values). If it's not, create a temporary index column and use that for merging.

M query - Edit the value of cell H2 in a table

Having imported an excel sheet into power query, I need to tidy it up by changing the value of a particular cell.
At the moment that cell has a null value, but there are other null values in the same column that I do not want to change. – So I cannot replace all of the null values in that column with another value.
I also cannot correct that particular cell in the source excel file (there are hundreds of them, which were created before I arrived).
I basically need some syntax for example that sets the value of cell H2 to “Jeep”, but not to change any other cells.
Very grateful for any insight.
One way would be:
In the Power Query Editor:
Add an index column starting from 1 (tab Add Column)
Add a Conditional column: If [Index] = 2 then Jeep else [H] (tab Add Column)
Delete Index column and [H] Column
Rename Custom column to [H].

POWER BI Creating new query out of existing one using range of columns

Trying to create a new query from the existing "Master" Query using below formula:
let
Source = Table.SelectColumns('Original Source Name',{'Column Name','Column Name2'})
in
Source
which works fine, however I am looking to see if there is any other formula which would do the same but in a way that it will create the new query with a range of columns , for example Column 30- 67 ( in this case when the original Excel file is updated, inserting a column in this range it would automatically update in the PBI too when refreshed)
Here's one possible way. If you start with this table, named Table1:
You can reference it in a new query like this:
let
Source = Table.SelectColumns(Table1, List.Range(Table.ColumnNames(Table1), 2, 3))
in
Source
...to get this:
The formula selects a range of columns from the table starting at the column at index position 2, and spanning 3 columns. (The index starts with 0.) For columns 30-67, you would change the 2 to 31 and the 3 to 37. You would change Table1 to your Original Source Name as well.
See these links for more info on List.Range and Table.ColumnNames.

Compare a value from two column and get matching value from another table Power BI

I am fairly new to powerbi and I need your help in one task on which I am stuck on.
Basically I have two tables and I need to compare the value from table one with a row of table 2 and return the output.
Table 1
I need to compare values in column a & b and get a match from table 2.
For example if row 1 has BY Green & BS HIGH then I need to check this value from matrix table below and return the output in column value as either 0 or 1.
Table 2
As you can see the Table 2 first row has value BY Green and BS low has a value '0'
Try this...
Index() returns a value from the matrix (in purple) based upon the intersections of the two match()'s. The first is the Vertical match in from the Table1:Col A; the second is the Horizontal match from table1:Col B. The value found at that intersection is returned.
... My apologies ... just saw this was a BI request... no worries...
First, Need fixup table2 as a lookup file:
First, click a cell in table 2 (don't edit), then Data menu >frm table/range, will bring up the Power Query window. Select columns B (not A) through Col F), then in the PQ Transform menu > Unpivot to create the new lookup table. this can either be saved as a new table or be used by reference.
Next, open and merge Table 1 PQ_Table 2 (Be sure to select BOTH Columns in BOTH Tables, in the same order). Then, expand the table tab following the merge expand the table tab. I only selected the value to return but you can return all the values to verify, then delete the unneeded columns.
Hope this helps...
Good Luck.

Sum values in one column of all rows which match one or more of multiple criteria

I have some table data in which I'd like to sum all the values in a specific column of all rows where column A contains string A and/or column B contains string B. How can I achieve this?
This works for one criterium:
=SUM(FILTER(G:G,REGEXMATCH(F:F,"stringA")))
I tried this, but it didn't work:
=SUM(FILTER(G:G,OR(ISTEXT(REGEXMATCH(F:F,"stringA")),ISTEXT(REGEXMATCH(C:C,"stringB")))))
Please try:
=SUM(FILTER(G:G,REGEXMATCH(F:F,"stringA")+REGEXMATCH(C:C,"stringB")))
+ works for or logic. ISTEXT is not needed because REGEXMATCH gives true or false.
OR does not work because filter is an arrayformula, use + in array formulas.
=SUM(FILTER(G:G,REGEXMATCH(F:F&C:C,"stringA|stringB")))
OR is denoted by |
EDIT Added &C:C to denote different Columns