Combining between Sumif and subtotal with tables in Excel - excel-2007

I have the following table in Excel
A - B - C
amount - type - tag
4 - Debit - nice
5 - Credit - nice
32 - Debit - bad
31 - Credit - bad
for calculation of total I used the following formula:
=sumif([type],"Credit",[amount])-sumif([type],"Debit",[amount])
I got 0, which is right.
but then I filtered the table to show "nice" tags only, but the result didn't change to 1, it remained 0.
How can I solve this problem so that subtotal is calculated when values are filtered according to tag?

Finally, I found a formula that works!
It doesn't work in Google sheets though...
=SUMPRODUCT(SUBTOTAL(109,OFFSET(D$2:D$160,ROW(D$2:$D$160)-ROW(D$2),,1)),--(E$2:E$160="CREDIT"))-SUMPRODUCT(SUBTOTAL(109,OFFSET(D$2:D$160,ROW(D$2:$D$160)-ROW(D$2),,1)),--(E$2:E$160="DEBIT"))

Related

Conditional formatting in webi Rich Client 4.1 of multiple values

I'm in BO 4.1 using a crosstab table. It is summary data based off specific detail information. Example:
Area-Days Late-Order #-Reason
1 - 5 - 12345-Lost
1 - 2 - 843254 - Lost
2 - 4 - 7532384 - Lost
1 - 7 - 12353 - Not home
So the output would be
Area 1 Area 2
Lost 2 1
Not home 1 0
Now for the conditional formatting part, I want it to highlight the Area 1 Lost cell as red because two of the orders are greater than 3 days late.
For whatever reason it seems to not be doing it because it's getting hung up line item 2 because that one is less than 3 days late.
Thank you!
I cheated and created a new object and then summed and did an if statement. Thanks for looking at this.

Filter the Google Finance formula to only display the "high" of all time

It's in reference to the Google Finance function in Google Sheets: https://support.google.com/docs/answer/3093281?hl=en
I would like to obtain the "all time LOW" (ATL) and "all time HIGH" (ATH) for a specific ticker (i.e. ABBV or GOOG) but only in 1 cell for each. Basically "What's the ATL/ATH value for this ticker?"
I've tried to do both formulas for ATL and ATH, but only ATL gives the expected result for now.
To get the ATL, you can use
=GOOGLEFINANCE("ABBV","low","01/12/1980",TODAY(),7)
and to get the ATH you can use:
=GOOGLEFINANCE("ABBV","high","01/12/1980",TODAY(),7)
The output of this is 2 columns of data:
Please note that column A, containing the timestamp, will be the one making trouble when it comes to computing the MAX function as it translates into some weird figures.
In order to get the ATL, I'll be using the MIN function which works perfectly fine:
=MIN(GOOGLEFINANCE("ABBV","low","01/01/1980",TODAY(),7))
as it will just scan the 2 columns of data and grab the lowest value which is 32.51 in USD.
BUT when I'm trying to do the same with MAX or MAXA for the ATH using for example
=MAX(GOOGLEFINANCE("ABBV","high","01/12/1980",TODAY(),7)
the result that comes out is 43616.66667 which seems to be a random computation of the column A containing the timestamp.
The expected result of the ATH should be 125.86 in USD.
I've tried using FILTER to excluded values >1000 but FILTER doesn't let me search in column B, so then I tried with VLOOKUP using this formula
=VLOOKUP(MAX(GOOGLEFINANCE("ABBV","high","01/12/1980",TODAY(),7)),GOOGLEFINANCE("ABBV","high","01/12/1980",TODAY(),7),2,FALSE)
but again it returns the value of column B but based on the MAX value of column A which end up giving me 80.1 and not the expected 125.86.
use:
=MAX(INDEX(GOOGLEFINANCE("ABBV", "high", "01/12/1980", TODAY(), 7), , 2))
43616.66667 is not a "random computation". it's date 31/05/2019 16:00:00 converted into a date value
MAX and MIN functions return single output from all possible cells in the included range which are in your case two columns. the date is considered as a number too so maxing out those two columns will output you the max value whenever it is from 1st or 2nd column. by introducing INDEX you can skip 1st column and look for a max value only in the 2nd column.
=MAX(INDEX(GOOGLEFINANCE("BTCSGD", "price", "01/12/1980", TODAY(), 7), , 2))
replace BTCSGD with any stock price you want to search up.
You can put ABCXYZ where ABC is the stock/ETF/Crypto and XYZ is the currency

DAX - Reference measure in calculated column?

I have data like this
EmployeeID Value
1 7
2 6
3 5
4 3
I would like to create a DAX calculated column (or do I need a measure?) that gives me for each row, Value - AVG() of selected rows.
So if the AVG() of the above 4 rows is 5.25, I would get results like this
EmployeeID Value Diff
1 7 1.75
2 6 0.75
3 5 -0.25
4 3 -1.75
Still learning DAX, I cannot figure out how to implement this?
Thanks
I figured this out with the help of some folks on MSDN forums.
This will only work as a measure because measures are selection aware while calculated columns are not.
The Average stored in a variable is critical. ALLSELECTED() gives you the current selection in a pivot table.
AVERAGEX does the row value - avg of selection.
Diff:=
Var ptAVG = CALCULATE(AVERAGE[Value],ALLSELECTED())
RETURN AVERAGEX(Employee, Value - ptAVG)
You can certainly do this with a calculated column. It's simply
Diff = TableName[Value] - AVERAGE(TableName[Value])
Note that this averages over all employees. If you want to average over only specific groups, then more work needs to be done.

Libreoffice Calc Finding MAX from a subset of results

I have a Libreoffice Calc workbook for tracking writing, with 3 sheets in it. 'Time Tracking', 'Time Summary' and 'Yearly Stats'. 'Time Tracking' is where user data is entered, 'Time Summary' is a pivot table for 'Time Tracking'; and 'Yearly Stats' shows long-term progress.
Time Summary (running off some test data) looks a bit like this:
|Column A (Weeks) | ... |Column M (Total Words)
-------+-----------------------+-----+----------------------
Row 7 |02/10/17 - 08/10/17 | |3500
Row 8 |13/11/17 - 19/11/17 | |2300
Row 9 |30/04/18 - 06/05/18 | |1000
Row 10 |30/10/17 - 05/11/17 | |700
Yearly Stats looks like this:
|A |B |C
-------+--------------------+--------+----
Row 1 | |2017 |2018
Row 2 |Total Words |6500 |1000
...
Row 7 |Max Words (Week) |3500 |3500
The formula for 'Yearly Stats'.B7:C7 is currently =MAX($'Time Summary'.$M$7:$M$10), but I need to modify it to filter by the year on the column heading.
https://ask.libreoffice.org/en/question/62260/minif-and-maxif-function-in-calc/ looked to be useful, but when I tried it, the MAX from the formula was returning the MAX of ROW - being 10 - rather than ROW returning the position of the MAX value - even though it seems to work in the example file from the link.
The example formula is:
=IFERROR(INDEX($Sheet1.$J$2:$J$13,MAX(ROW($Sheet1.$J$2:$J$13)*($Sheet1.$A$2:$A$13=A2))-1,1),NA())
My formula uses RIGHT() to compare the last two characters of the column heading with the last two chars of the week in $'Time Summary':$A$7:$A$10 and is:
=IFERROR(INDEX($'Time Summary'.$M$7:$M$10,MAX(ROW('Time Summary'.$M$7:$M$10)*(RIGHT($'Time Summary'.$A7:$A$10,2)=RIGHT(B1,2)))-6,1),NA())
I have, of course, remembered to press CTRL+SHIFT+ENTER as the instructions say, to get the array in the formula to work.
So that's the explanation of my problem. What is it that I'm getting wrong?
Ok, this is a bit long-winded, but I've managed to solve the problem by using the following formula:
=IF(MAX(IF(RIGHT(INDIRECT(CONCATENATE("$'Time Summary'.$A7:$A$",COUNTIF($'Time Summary'.$A:$A,"<>''")+2)),2)=RIGHT(B1,2),INDIRECT(CONCATENATE("$'Time Summary'.$Q$",ROW(INDIRECT(CONCATENATE("$'Time Summary'.$Q7:$Q$",COUNTIF($'Time Summary'.$Q:$Q,"<>''")+5))))),0))>0,MAX(IF(RIGHT(INDIRECT(CONCATENATE("$'Time Summary'.$A$7:$A$",COUNTIF($'Time Summary'.$A:$A,"<>''")+2)),2)=RIGHT(B1,2),INDIRECT(CONCATENATE("'Time Summary'.$Q",ROW(INDIRECT(CONCATENATE("$'Time Summary'.$Q$7:$Q$",COUNTIF($'Time Summary'.$Q:$Q,"<>''")+5))))),0)),NA())
It is wrapped in an IF that replaces any 0 result with '#NA' (just for neatness of output).
Also the right half of the ranges specified make use of a calculation to figure out where the bottom row is, leaving out the total, so that's another reason it's so huge.

Conditional Probability with Powerpivot

my major goal is to calculate Conditional Probability over a large number of rows. Hence the use of Powerpivot.
Attached is an excel file with 10 rows as an example of how I did it in Excel.
My challenge is the formula in column F which I will then be needing to calculate column G.
Tamir
Can you check the solution
Main Formulas:
Calculate a Total, without filtering BRAND and UPS (calculated measure)
=CALCULATE([Total],All(Brand),All(upc))
Sum IF UPC (calculated column):
=CALCULATE([Total],filter(ALL(Fact),Fact[UPC]= EARLIER(Fact[UPC]) ))