How to sum negative numbers in a pivot table using calculated fields? - excel

I've got some accounts data that I'm trying to manipulate and present but I can't seem to figure this out... I've got an "Amounts" (£) column (among many others) that I've put into a pivot table and I'm trying to use the calculated field function to separate the minuses (income) from the positives (expenses), but it won't allow me to when I enter the formula. Any suggestions? [without manipulating the source data!]
So, I've already tried entering the formula: =IF(Amount<0, Amount, 0) for income (as a negative would be, in my case, an income). I've also tried =Amount<0 and =IF(Amount<0, Amount*1, 0), but none seem to work at all. SOS!

Related

SUMIF with Index and multiple match criteria with Dynamic range

enter image description here
In the above problem, I am trying to create a dashboard of Brands Category wise.
The formula i am trying is. THis is in google sheets.
=INDEX($A$1:$F6,ArrayFormula(MATCH(A$12&B12,$A$1:$A6&$B$1:$B6,0)),Match(to_text(C$11),$A$2:$F$2,0))
THis returns only 1 value . But I would like to get a sum of BrandA, Catgory1 both in Nos and Pcs. How do I go about doing it? Somehow, not able to work with SUMIF. what is best suited?
Actually trying to create a dashboard for Month wise Sales/Purchase data like the link below. Any better way of doing in?
https://docs.google.com/spreadsheets/d/1047uWOrOqkW3L_1hoKh-MaY-O0_CZC0WiqmV8HZqk6o/edit?usp=sharing
Raj, if I understand your question, the following formula might provide the result you want.
=QUERY(Data!A1:F,"select A,B,sum(D),sum(E),sum(F)
where A<>'' group by A,B order by A,B
label sum(D) 'Apr',sum(E) 'May',sum(F) 'June' ",1)
This queries your data, groups it (and sorts) by brand and category (ignoring the Unit type) and sums the values. It also modifies the header text for the three summed columns.

Manually change Numeric parameters for OLAP formula

I had created a Pivot which uses Power Bi model as it's data source (Analysis services). Since my data is huge and there limitations of pivot, I am exploring other ways of pulling the data.
I converted the sample Pivot to Olap Formula and I think this is the best solution from all the options I have explored. But there is some odd situation I am facing where I need some help.
I tweaked the structure as shown below. So now whenever I change any string like in the below example if I manually change the currency from SGD to USD, I am getting the result. But whenever I try to Manually change any numeric value like Segment, I am getting #N/A. The same numbers when pulled using pivot gives the number.
I have tried to insert the numeric value in following ways
40
'40
="40"
=text("40",0)
text to columns->text
but till now I am not able to crack this.
The cubevalue function expects dimensions on which it is going to filter the values. If you want to provide the value manually you'll have to do it like this:
=CUBEVALUE("Sales","[Measures].[Profit]","[Time].[2004]","[All Product].[Beverages]")
Meaning you'll have to change the 40 to something like [MyDimension].[MyHierarchy].[40]

Column to rows and highlight difference between values in the same group

I have a huge table with data structured like this:
And I would like to display them in Spotfire Analyst 7.11 as follows:
Basically I need to display the columns that contain "ANTE" below the others in order to make a comparison. Values that have variations for the same ID must be highlighted.
I also have the fields "START_DATE_ANTE" and "END_DATE_ANTE" which have been omitted in the example image.
Amusingly, if you were limited to just what the title asks, this would be a very simple answer.
If you wanted this in a table where the rows are displayed as usual, and the cells are highlighted, you can do this by going to properties, adding a newGrouping where you select VAL_1 and VAL_1_ANTE and add a Rule, Rule type "Boolean expression", where the value is:
[VAL_1] - [VAL_1_ANTE] <> 0
This will highlight the affected cells, which you can place next to each other. You can even throw in a calculated column showing the difference between the two columns, and slap it on right next to it. This gives you the further option to filter down to only showing rows with discrepancies, or sorting by these values.
However, if you actually need it to display the POSTs on different lines from the ANTEs, as formatted above, things get a little tricky.
My personal preference would be to pivot (split/union/etc) the data before pulling it in to Spotfire, with an indicator flag on "is this different", yes/no. However, I know a lot of Spotfire users either aren't using a database or don't have leeway to perform the SQL themselves.
In fact, if you try to do it in Spotfire using custom expressions alone, it becomes so tricky, I'm not sure how to answer it right off. I'm inclined to think you should be able to do it in a cross table, using Subsets, but I haven't figured out a way to identify which subset you're in while inside the custom expressions.
Other options include generating a table using IronPython, if you're up to that.

Excel - Return name from list based on multiple criteria

This is my 1st post here (and not allowed to paste images). I have been trying to solve this issue for a couple of days with no luck. I'm working on an Excel spreadsheet for a game and cannot return a name based on multiple criteria. See below:
Table
I am trying to return, for example, the name of the Guardian with the highest amount of games played.
I've tried Index/match/sumproduct combinations but I can't figure this one out. Can you help me?
=index(Data!$A:$H,match((1,Data!B:B=Overview!B12)*(Data!C:C=Overview!B23)),0),1)
=MAX(IF(Data!B:B=Overview!B12,Data!C:C))
I'm thinking if I could join these two formulas together I might be able to make it work.
Try this array formula:
=INDEX(Data!$A1:$A99,MATCH(MAX(Data!$C$1:$C$99*(Data!$B$1:$B$99=B12)),
Data!$C$1:$C$99*(Data!$B$1:$B$99=B12),0))
CtrlShiftEnter
Notice that we should avoid using "full columns" in array formulas because they would introduce the computation of huge arrays and hence would slow down the formulas. I limit it here to 99 rows, use a limit that is big enough to span your data.

Excel - Nested IF/Nested AND/OR in 'calculated field' option - pivot table

I have the following problem:
A datasheet with a column (HOUR) and another column (AM/PM). Entries in the first column consist of 1,2,3,4,5,6,7,8,9,10,11, or 12, the second column consists of 'AM's or 'PM's. Together they define the time of an incident (regarding the below problem, note that I am not allowed to create a new column in the source datasheet or change existing columns). The below formulas 1.) to 3.) work excellent for getting '1's or '0's for incidents that happened either between 8AM and 4PM, or outside of this time window, as long as I create a new column somewhere.
1.) =IF(AND(A1>=8, A1<=11),IF(B1="AM",1,0),0) + IF(AND(A1>=1, A1<=4),IF(B1="PM",1,0),0) + IF(AND(A1=12),IF(B1="PM",1,0),0)
2.) =--OR(AND(A1>=8, B1="AM", A1<>12), AND(OR(A1<=4, A1=12), B1="PM"))
3.) =--OR(AND(OR(A1={8,9,10,11}),B1="AM"), AND(OR(A1={1,2,3,4,12}), B1="PM"))
However, I want the "1"s to be summarized - without creating an extra column - as calculated field in a pivot table. While excel doesn't accept the 3.) formula at all in the calculated field option, excel accepts 1.) and 2.), but puts out only "0"s in all pivot cells. The below is one of the formulas that puts out only "0"s in the pivot table.
=--OR(AND(HOUR>=8,'AM/PM'="AM",HOUR<>12), AND(OR(HOUR<=4,HOUR=12),'AM/PM'="PM"))
The field value settings don't make a difference, and the fields that are created new with 1.) or 2.) cannot be filtered for "1"s or 0"s, so something must be wrong with the field calculation I guess. Does anybody know what I need to change to make it work? Are there special rules for formulas in pivot tables that apply to formula 1.) and 2.) to make them work?
Thanks for any help on this
I think the limitation is not you, but Excel.
See here for description of what is possible, as well as this question
I tried your code and indeed I see it's not working. Even with a simple if code it doesn't seem to work. I think it's is explicitly called a calculated field because you are only able to calculate the fields in the Sum/Total/Count etc. column.
Have a look at MS, this function is quite limited.
I would try to make another work-around to accomplish your goal.
Microsoft

Resources