Related
I have a number of datasets on a sheet that calculate monthly and annual staff hires and terminations. I have another dataset to calculate the annual running staffing totals for specific disciplines by subtracting one specific row from another. The funcion I use is:
=LET(duration, SEQUENCE(1,(StudioProjectedOperatingMonths+12)/12, COLUMN(K:K)),
StartRow, 25,
RowsUntilSecondRow, 44,
DisciplineEntryIndex, ROW(INDEX(DisciplineTbl[Discipline],MATCH(J113,DisciplineTbl[Discipline],0)))-ROW(DisciplineTbl[#Headers])-1,
FirstRow, StartRow+DisciplineEntryIndex,
SecondRow, StartRow+RowsUntilSecondRow+DisciplineEntryIndex,
DisciplineValues, INDEX($1:$84,{25;69},duration),
StaffInOut, LET(x, DisciplineValues,INDEX(x,1)-INDEX(x,2)),
SCAN(0, StaffInOut,LAMBDA(x,y,x+y))
)
This gives the correct result when inserted in to K113 (highlighted cell below):
However, when I drag copy the formula from K113 to K114 etc I have to adjust the row references in the Index function to be INDEX($1:$84,{26;70},duration) and so on.
To try and get around this, I created the variables FirstRow and SecondRow which start off at 25 and 69 as per the Index part of the full formula above, and use the indexed row of the discipline in the discipline table to add a value. For example, if the Discipline is Programming it will add 0, if Design it will add 1 etc.
My thinking was to replace the INDEX($1:$84,{25;69},duration) part of the formula with INDEX($1:$84,{FirstRow;SecondRow},duration) but unfortunately it doesn't like this syntax.
Is there a way to make this work or do I need to approach it differently?
I have an NFL spreadsheet where each row represents a specific team, and every 5 columns represents weekly information about the team (Column A is the team, Columns B-F are stats for week 1, G-K are stats for week 2, etc.). I am trying to perform different calculations on information from the same stat for each week (I.E. sum of columns B,G...). One column includes the teams margin of victory for each week. In order to calculate the teams Win/Loss record, I attempted to use a COUNTIF() function, counting each Margin of Victory column for each week - count a Win for each week where the MOV is greater than 0, Loss for less than zero.
=COUNTIF((Weeks!E3,Weeks!J3,Weeks!O3,Weeks!T3,Weeks!Y3,Weeks!AD3,Weeks!AI3,Weeks!AN3,Weeks!AS3,Weeks!AX3,Weeks!BC3,Weeks!BH3,Weeks!BM3,Weeks!BR3,Weeks!BW3,Weeks!CB3,Weeks!CG3),>0)
The result is a formula parse error, because I've entered too many arguments for the COUNTIF() function (although my assumption was adding parentheses around the data would make it one argument). The desired outcome, reference the picture for example, would be on another sheet to produce 1 loss and 1 tie (in separate cells) for Arizona (Week 1 margin = 0, week 2 margin = -6), and then replicate this over the course of 17 weeks as implemented in the formula.
Maybe some of these formula's:
For positive results:
=SUMPRODUCT((MOD(COLUMN(A3:CG3),5)=0)*(A3:CG3>0))
Or:
=SUM(INDEX((MOD(COLUMN(A3:CG3),5)=0)*(A3:CG3>0),))
For draws:
=SUMPRODUCT((MOD(COLUMN(A3:CG3),5)=0)*(A3:CG3=0))
Or:
=SUM(INDEX((MOD(COLUMN(A3:CG3),5)=0)*(A3:CG3=0),))
For negative results:
=SUMPRODUCT((MOD(COLUMN(A3:CG3),5)=0)*(A3:CG3<0))
Or:
=SUM(INDEX((MOD(COLUMN(A3:CG3),5)=0)*(A3:CG3<0),))
Change A3:CG3 to whichever range it actually goes to.
Instead of making a large countif, you can sum all of the individual countif functions.
=SUM(COUNTIF(Weeks!E3,">0"),COUNTIF(Weeks!J3,">0")...
So on and so forth. Since each countif function will return either a 0 or 1, summing all of those together should hopefully work. It might be a little annoying but this is how I've made formulas like that work. Let me know if this works for you.
I have some weekly stock return data that looks like this:
I've hidden a lot of rows there, obviously. But basically there are 200ish different stocks and their weekly returns over the course of 10 years. They are paired with a return in column E for the same period for the S&P 500. I want to calculate betas with these Covariance(Stock, S&P 500)/Variance(S&P 500). I'm struggling just to create the Covariance portion right now:
Column A in my new sheet is a unique list of all the ticker symbols and my formula is as follows:
=COVARIANCE.P(INDIRECT("'Weekly Data'!D$"&MATCH(A2,'Weekly Data'!F:F,0)&":'Weekly Data'!D$"&MATCH(A2,'Weekly Data'!G:G,0)),INDIRECT("'Weekly Data'!E$"&MATCH(A2,'Weekly Data'!F:F,0)&":'Weekly Data'!E$"&MATCH(A2,'Weekly Data'!G:G,0)))
Getting a #REF error.
Your concatenation
"'Weekly Data'!D$"&MATCH(A2,'Weekly Data'!F:F,0)&":'Weekly Data'!D$"&MATCH(A2,'Weekly Data'!G:G,0)
leads to the wrong string representation of a cell range address.
It leads to 'Weekly Data'!D$2:'Weekly Data'!D$528 in case of ORCL. But in Excel it would must be 'Weekly Data'!D$2:D$528. Note, the sheet name only once.
So correct formula would be
=COVARIANCE.P(INDIRECT("'Weekly Data'!D$"&MATCH(A2,'Weekly Data'!F:F,0)&":D$"&MATCH(A2,'Weekly Data'!G:G,0)),INDIRECT("'Weekly Data'!E$"&MATCH(A2,'Weekly Data'!F:F,0)&":E$"&MATCH(A2,'Weekly Data'!G:G,0)))
But as often INDIRECT could be replaced by INDEX. This is the better approach because of the volatile behavior of INDIRECT, which gets recalculated on each change in sheet and not only on change of the cells in function parameters.
The INDEX formula would be:
=COVARIANCE.P(INDEX('Weekly Data'!$D:$D,MATCH(A2,'Weekly Data'!$F:$F,0)):INDEX('Weekly Data'!$D:$D,MATCH(A2,'Weekly Data'!$G:$G,0)),INDEX('Weekly Data'!$E:$E,MATCH(A2,'Weekly Data'!$F:$F,0)):INDEX('Weekly Data'!$E:$E,MATCH(A2,'Weekly Data'!$G:$G,0)))
In my source data I've got a columns with data for every month and for few years.
In my working spreadsheet I want to sum the source data with 4 criteria. 3 of them are constant and one is dynamic (Month&Year). Depends on the chosen month and year I want to sum correct column in source data.
I've found a similar topic - link below:
SUMIF dynamically change summing column
However, I am getting #Values error if I input a formula. I've check that all data is text and compare with Exact function as well.
Below is my formula:
=SUMIFS(INDEX(IBRACT[#All];0;MATCH(Sheet3!G$1;IBRACT[#Headers];0));IBRACT[Entity];$A$1;IBRACT[SKU];$D14)
IBRACT is the name of table.
Below is the link to screen of evaluation (in this example I wanted to sum 6th column which in the spreadsheet is column "F"). Next step of evaluation shows #Value.
https://imgur.com/JHq80BM
Have anybody any idea how to solve this problem?
Best,
Wiktor
IBRACT[#All] includes the header row which is one row more than the two criteria ranges, hence the #VALUE! error. Just change the sum range to only include the data body range.
=SUMIFS(INDEX(IBRACT; 0; MATCH(Sheet3!G$1; IBRACT[#Headers]; 0)); IBRACT[Entity]; $A$1; IBRACT[SKU]; $D14)
I have been tasked with converting a a worksheet from standard Excel into PowerPivot. However, I have hit a roadblock with the PERCENTRANK.INC function which is not available in DAX. I have come close to replicating it using a formula, but there are definite differences in the calculation.
Does anyone know how Excel calculates PERCENTRANK.INC()?
Formula in cell D2: =(COUNT($A$2:$A$10)-B2)/(COUNT($A$2:$A$10)-1)
Formula in cell B2: =RANK.EQ(A2,$A$2:$A$10,0)
Formula in cell C2: =PERCENTRANK.INC($A$2:$A$10,A2)
Edit:
It's seems strange to me that there are so many "standard" ways to calculate PERCENTRANK that has have slightly different results.
Using your example of your 9-number set of 1,2,3,4,4,6,7,8,9, depending on which "authority" I used, the third value (3) had a Percent Rank of 25.0%, 27.0%, 27.8% or 30.0%.
Obviously we'll go with the one that gives your desired result, matching PERCENTRANK.INC.
PERCENTRANK.INC is calculated as:
[count of values lower than the given value]
÷
[count of all values in the set excluding the given value]
so, if our range of 1,2,3,4,4,6,7,8,9is in A1:A9, we could use this formula in B1:
=COUNTIF($A$1:$A$9,"<"&A1)/(COUNT($A$1:$A$9)-1)
...and copy or "fill" it down for results:
0.0%, 12.5%, 25.0%, 37.5%, 37.5%, 62.5%, 75.0%, 87.5%, 100.0%
Original Answer
I think you just want to calculate the PERCENTRANK for current row
value. Based on the logic for PERCENTRANK, we can add a RANK column in
table and achieve same logic based on this column.
Create a Rank column.
Rank = RANKX(Table6,Table6[Value])
Then create the PctRank based on the Rank column.
PctRank = (COUNTA(Table6[Name])-Table6[Rank])/(COUNTA(Table6[Name])-1)
(Source)
For reference here is the DAX formula based off ashleedawg's answer which includes ignoring cells with no values in them.
=ROUNDDOWN(COUNTROWS(FILTER('Lookup_Query','Lookup_Query'[Entrances]<EARLIER('Lookup_Query'[Entrances]) && ISBLANK('Lookup_Query'[Entrances])=FALSE()))/(COUNTROWS(FILTER('Lookup_Query',ISBLANK('Lookup_Query'[Entrances])=FALSE()))-1),3)