Using Array Formula with Median and IF - if-statement

I'm trying to find the median of a column based on two conditions. I thought using an ArrayFormula is best since there is no "medianifs"...I'm getting a result in my first cell but when I try to change the criteria in the cell beneath, you'll see I'm getting the exact same result, so I know something is wrong. Maybe the formula in the first cell isn't even the correct answer?
Here's my sheet.
I'm down in P94 and P95 trying to get the median values, you'll see the formulas that I've tried thus far.

Based on what you are attempting, I would use a filter to narrow down the criteria.
=MEDIAN(FILTER(N:N,F:F=O1,I:I=P1))
That way the data you are taking the median of is always the exact dataset needed.

Related

How do I run an Excel formula in one cell (have it produce a value) ONLY if another cell's formula produces a value?

I want to run this Excel formula:
=IFERROR(INDEX(Y163:AA163,MATCH(TRUE,Y163:AA163<>"",0)),"")
But ONLY if the formula in cell B163 produces a result/value.
I've tried different formulas but cell X163 still produces a value even though B163's formula has not produced a value.
Example formulas I've tried:
=IFERROR(IF(LEN(B163)<>"",(INDEX(Y163:AA163,MATCH(TRUE,Y163:AA163<>"",0)),""),"")
=IFERROR(IF(B163<>0,(INDEX(Y163:AA163,MATCH(TRUE,Y163:AA163<>"",0)),""),"")
In other words, I want a formula in X163 that states that if B163's formula results in a value or is not equal to 0, then run the formula beginning with "INDEX." On top of this, put this all in an IFERROR statement, because that's what I do with all my formulas. So there are a lot of nested formulas/statements.
How can I get this new condition to override other conditions?
Drop the IFERROR in your second formula.
Based on your description use:
IF(OR(B163<>0,B163<>""),INDEX(Y163:AA163,MATCH(TRUE,Y163:AA163<>"",0)),"")
These formulas worked:
=IFERROR(IF(B163>0,INDEX(Y163:AA163,MATCH(TRUE,Y163:AA163<>"",0)),""),"")
...or
=IFERROR(IF([#Total]>0,INDEX(Y163:AA163,MATCH(TRUE,Y163:AA163<>"",0)),""),"")

If statement based on presence of duplicates

If the data in column A is found in multiple rows, look at the data in column C for those duplicate rows. Whichever is highest value in C, return the value from the respective row but column B. In my picture, I'm trying to populate the stuff in yellow automatically, ideally with formulas in excel. Any help is greatly appreciated.
enter image description here
My first attempt was this (a formula that you may copy on cell D2):
=INDEX($A$2:$C$9,MATCH(MAX(IF($A$2:$A$9=A2,$C$2:$C$9)),$C$2:$C$9,0),2)
This is what it does: the combo INDEX-MATCH does what VLOOKUP does, but it is more efficient than VLOOKUP. Basically it commands Excel to navigate the $A$2:$C$9 range and then find the following match:
Find the row with the MAX price for the same Item (this part: MAX(IF($A$2:$A$9=A2,$C$2:$C$9)));
Then return whatever value is on column B, at that row.
Albeit this formula seemed to work, I tried something out: what if, by some unfortunate coincidence, the MAX price for two items was the same?
This is what happens when CDE888 sells for 217
Thus, one can tell the formula above is wrong and needs a fix. This is the new formula:
INDEX($A$2:$C$9,MATCH(A2&MAX(IF($A$2:$A$9=A2,$C$2:$C$9)),$A$2:$A$9&$C$2:$C$9,0),2)
This time, the formula looks for a value that is composed of the Item code AND its highest price.
The rest works exactly as the first formula.
One last word: I wrote this formula on cell D2, then dragged the formula down.

Virtual array to be used into VLOOKUP and SUMIF formulas

I have the following tables
In Table 1 I have some items with relative quantity values. Beneath, I have a look-up table from which I can find the rule for summing up the item's quantities into the right Container.
Currently I use additional columns, one for each Container, for helping in succeding the task.
Each cell in additional columns has the following formula (ex. E4):
=IF(VLOOKUP($B4,$D$12:$G$17,MATCH(E$2,$D$11:$G$11,0),0)="x",1,0)
Then, each Container has a Sum of Values calculated as follow (ex. E3):
=SUMPRODUCT($C$4:$C$9,E$4:E$9)
The question is... Is there a way (no VBA) to obtain the same result without using additional helping columns?
I would like using something like this as formula (but it doesn't work):
=SUMPRODUCT($C$4:$C$9,IF(VLOOKUP($B4:$B9,$D$12:$G$17,MATCH(E$2,$D$11:$G$11,0),0)="x",1,0))
In short, I don't know if (and if yes, how) the helping columns in the sheet I use can be calculated on the fly from excel as virtual columns directly into a cell formula.
No limitations in the use of VLOOkUP and SUMIF functions -> SUMIF, SUMIFS, INDEX, MATCH and any other combination of Excel functions is fine as long as the goal of eliminating the help columns is achieved.
Any help on this would be really appreciated.
Thanks in advance to everyone
Try,
In E3, modified your formula and copied across right to G3 :
=SUMPRODUCT($C$4:$C$9,IF(VLOOKUP(T(IF({1},$B4:$B9)),$D$12:$G$17,MATCH(E$2,$D$11:$G$11,0),0)="x",1,0))
Or,
=SUMPRODUCT($C$4:$C$9*(VLOOKUP(T(IF({1},$B4:$B9)),$D$12:$G$17,MATCH(E$2,$D$11:$G$11,0),0)="x"))

Power-BI: Add column in Data-Area or Add Column in Power-Query

I am wondering where the difference in both approaches lie.
Basically I want to add a column which indicates as a result with TRUE or FALSE if a data row is inside my time period I have to consider (all values older than current calender week - 1).
For my understanding I have two options:
Option 1:
I modify my data query and add a new column with a formula like this in Power-Query:
DATEDIFF(WEEKNUM([created].[Date]),WEEKNUM(TODAY()),WEEK)
Option 2:
I use the Data-Section in Power-BI and add a column wiht this formula:
DATEDIFF(WEEKNUM([created].[Date]),WEEKNUM(TODAY()),WEEK)
What is the difference of both approaches, using either the backend PowerQuery vs the Data-Section in Power-BI. Is one more favourable?
Common answer in PowerPivot world suggests calculated columns are very costly, therefore better to choose PowerQuery to do the data preparation work. I suppose it depends on how many rows you have and how many other calculations you are asking PP/DAX to do as you are now storing a value that can be easily calculated.
Independent of "cost", I tend to use DAX for dynamic calculations and land more static values using PQ/M which allows for some very creative extract/transform/load (ETL). Think of it this way: if you put the formula in Excel, calculate for 1MM rows it has to recalculate every time you do, well, anything. So what do you do? Use the formula to calc the value then paste values so you just keep the answer. PQ can deliver the final result and drop the calcs or -- better -- intermediate data.
JR

Vlookup to compare two tables

IF(ISNA(VLOOKUP(Table1,Table2,1,FALSE)),"No","Yes")
I want compare all the columns for two tables within a single excel sheet and I used the above formula but somehow the formula always gives "Yes" irrespective of whether the values match or not. Can someone please help me out to get correct comparison results.'
Thanks
Please see the snapshot below
Formula will be as below. Kindly take this as example and work out as per your wish.
=IF(VLOOKUP(G1,$A$1:$B$7,2,FALSE)=VLOOKUP(G1,$D$1:$E$7,2,FALSE),"Same","Different")