Reference a cell using IF inside VLOOKUP on Google Sheets - if-statement

I want to perform a vlookup with an if statement inside. I currently have
=LOOKUP("Metallic Gold Flash Tattoo Arabic",A:A,IF(INDIRECT(ADDRESS(ROW(), E)))<0,INDIRECT(ADDRESS(ROW(), C)),0)
I want to sum up all the units of that product type in column A, however I only want to sum up the ones that have been sold and not bought. Column C is units and E is price. Sold are positive and negative are bought.
I am using Google Sheets.

I'm assuming you want to sum column C (quantity of units) when the description matches in column A and col E is > 0
Try using SUMIFS - that should work in both excel and google sheets, i.e.
=SUMIFS(C:C,A:A,"Metallic Gold Flash Tattoo Arabic",E:E,">0")
....or do you want to get the total cost price of those units (Col C multiplied by E for the relevant rows)?
For that you can use this formula in google sheets
=sum(filter(C:C*E:E,E:E>0,A:A="Metallic Gold Flash Tattoo Arabic"))

You could try a query:
=QUERY(A:E, "SELECT A, SUM(E) WHERE A = 'Metallic Gold Flash Tattoo Arabic' AND C > 0", 1)
I'm assuming that column C contains the positive and negative values indicating sold and bought.

Related

Wrong calculations for rows in Power BI matrix

I am trying to calculate market share, but struggling with doing it correctly.
I have a matrix where I have Category, Name as rows, Channel as column, and Market Share as value.
Also In my dataset I have columns ABS_COMPANY (with sales inputted there if company = "A", so there are some blank ones), and ABS_TOTAL (with sales inputted in each row)
so my measure Market Share:
Market Share = SUM(table\[ABS_COMPANY\]) / SUM(table\[ABS_TOTAL\])
This correctly calculates values for each Category, but when I open the drop-down to see Name, Market Share of each Name equals to 100%. What is the problem and how to fix it?
e.g. What is now:
Market Share
Pens 43%
pen 1 100%
pen 2 100%
pen 3 100%
Pencils 29%
penc 1 100%
penc 2 100%
penc 3 100%
I've tried using Calculate(), but it does not work in a way I want to.
Unfortunately, I cannot share the data as it is sensitive.
Structure of dataset:
NAME STRING
CATEGORY STRING
CHANNEL STRING
ABS_COMPANY DECIMAL(20,2) - value of sales for each name
ABS_TOTAL DECIMAL(20,2) - it is a value grouped by CHANNEL AND CATEGORY at the backend

Sum regex extraction in Google Sheets

In my Google spreadsheet document, I have a table of bills with a column J for dates and a column P for amounts. I would like to build another table that sums these bills by year (one row = one year). The P column has contents like "3245,20 EUR".
Here is the formula I tried (in this example, S5 should be the sum and R5 a numeric value of a specific year) :
S5=SUMIF(YEAR($J$5:$J), R5, VALUE(REGEXEXTRACT($P$5:$P, "^([0-9]+,[0-9]{2}) EUR$")))
This doesn't work. Any solution ? Thank you.
You can use the following formula
=SUM(QUERY({A2:A,ArrayFormula(VALUE(REGEXEXTRACT(SUBSTITUTE(B2:B,",","."), "^([0-9]+\.[0-9]{2}) EUR$")))},
"select Col2 where year(Col1)="&A1&""))
The reason we have to use SUBSTITUTE is because it looks like the price values come from a different locale.
(Please adjust ranges to your needs)
Functions used:
QUERY
ArrayFormula
VALUE
REGEXEXTRACT
SUBSTITUTE
SUM

Lookup last value in sheet where other cell contains value

I'm trying to find the last instance of a value in a sheet. The value is an amount of currency, and the condition should be if the type of currency is Income. For example, I have a sheet with
Date Name Amount Type
2019-08-01 Cash on hand 52.52 Income - Allowance
2019-08-02 Cash on hand 33.33 Income - Hourly
and I want to match the latest amount of income (33.33) and display it in another cell.
I've tried something like =INDEX(FILTER(A:A;NOT(ISBLANK(A:A)));ROWS(FILTER(A:A;NOT(ISBLANK(A:A)))) from Get the last non-empty cell in a column in Google Sheets where instead of NOT(ISBLANK()) I tried to put "Income*. I also tried to do a chain of MAX(FILTER()), but I got an error:
FILTER has mismatched range sizes. Expected row count: 999. column count: 1. Actual row count: 1, column count: 1.
Any help would be much appreciated.
=QUERY(A2:D, "select C where D matches 'Incom.*' offset "&COUNTA(
QUERY(A2:D, "select C where D matches 'Incom.*'", 0))-1, 0)

Create Calculated Column Based on Teams with Four Wins in Final Round Utilizing DAX

I need a calculated column for champions and runner up. To become a champion, a team must attain 4 wins in a given year in the final round. I just don't know how to translate that for DAX. I want to be able to have a Year Slicer that will show the Champion and Runner Up for a given year in a card.
I have tried a summary table and using TOPN, but since the count of finalists are all one, I am getting no luck. In the picture below, I would like a column delegating if a team is a champion or runner up
Create a new column by clicking in the Modeling tab and selecting 'New Column". Using the code below I created a new column which takes the column which contains the 'Count of Champions' and IF the number is greater than or equal to 4 then "Champion" is placed in the adjacent column, if the number is below 4, then "Runner Up" is placed in the adjacent column.
Status = IF(Table1[Count of Champions] >= 4, "Champion", "Runner Up")

Dax Filter the count of If

I am trying to create a calculated column for Champions. Each year, a team that attains 4 wins in the final round is the champion. Basically, I need a DAX statement that translates to "when a Team in a given year has a count of 4 wins in the final round they are that year's champion"
I just don't know how to do this in DAX. I have tried a summary table to no avail. I know I need to Calculate and Filter but it is the Count of Wins for a given year that is given me trouble. Essentially, the Image below should have a champions column. Ignore the title of this image, it is supposed to say "Count of Finalists"
You may show only winner team in table by applying visaul filter using this measure,
Is Champion = IF ([Count of champion] = 4 ,"YES","NO")