CASE WHEN not working in Spotfire - switch-statement

I am having some trouble with a CASE WHEN argument well its probably more to do with the OVER function any help would be greatly appreciated. The error I am getting is 'The expression is not valid after OVER on line 2 character 51'
The expression I have so far is
CASE
WHEN [Pay in 2015] = 1 and [Reimburse in 2016]= 1 OVER ([Customer ID]))>=2 then 2
ELSE 0
END
Any help would be greatly appreciated

Try something like this... you may have to play with what you intersect for your specific data. It's hard to test without your data.
case
when
sum([Pay in 2015]) over (intersect([CustomerID],[Amount],[Date of Payment])) >= 2
and
sum([Reimburse in 2016]) over (intersect([CustomerID],[Amount],[Date of Payment])) >= 2
then 2
else 0
end
EDIT
After looking at your data there I don't see a way to do this without a unique identifier for each charge and reimbursement. For example, in the data you pasted there are 4 charges. 2 for 80 and 2 for -80 meaning these would offset. However, what if there was another for 80 for the same Nature and Purpose? There isn't any expression that would be able to like the two credits to any two charges while ignoring the last one. Generally speaking you really need an ItemID or something that specifies a unique identifier for the charge and charge back. Otherwise, someone could credit an account with 80 bucks or 150 and there is no real way of telling what specific item that was for (what travel voucher, etc).
The best think you could do right now is look at the customer as a whole and return the total amount they were charged compared to the total amount they were credited, but reconciling each row isn't possible with guaranteed accuracy without the unique chargeID / coucherID / etc.
Sorry.

Related

I am learning and trying to use multiple IFS with AND, OR, NOT function in excel, but it was returning #VALUE

This is the formula that I made:
=IF(AND(ISNUMBER(SEARCH("Tip Top";E4));ISNUMBER(SEARCH("Hari Hari";E4));F4>25);10000*F4;5000*F4);IF(AND(NOT(ISNUMBER(SEARCH("Tip Top";E4)));NOT(ISNUMBER(SEARCH("Hari Hari";E4)));F4>25);15000*(F4/6);(F4/6)*5000)
I have tried to modify the formula, but it gives error:
'You've entered too many arguments for this function'
I am trying to return this:
-Daily Incentive for SPG's in Tip Top & Hari Hari : 10.000 IDR/sachet in case sales > 25 sachets, 5.000 IDR/sachet in case sales < 25 sachets.
-Daily Incentive for SPG's in all other stores : 15.000 IDR for every 6 sachets sold in case sales > 25 sachets, 5.000 IDR for every 6 sachet solds in case sales < 25 sachets.
Can anyone tell me where I did wrong? The error value and the needs to really solve this problem always linger in my mind. I think I can't sleep peacefully if I hadn't found where I did wrong.
Thank you so much, your guidance is much appreciated!
whats going on at 10000F4;5000F4 ? missing < or > or =
Writing long equations in excel is difficult to trouble shoot. I recommend copy pieces of the formula and place them into other cells and see if it returns what you expect.
For instance I would copy a segment like below and put an "=" in another cell and paste:
=NOT(ISNUMBER(SEARCH("Hari Hari";E4)))
repeat the process until you find the error.
Other methods to resolve this is to use ifs(), switch(), or stop using excel functions and use power query for excel or other tools.

Excel 2013, multiple search criteria to back fill empty fields, large database

item
countDate
shopID
lineNumber
defectNumber
jobID
jobID2
123A1234-123
1/1/2022
1234
1
123A1234-123
1/2/2022
1234
2
123A1234-123-AB123
1/1/2022
AB12C
1234
0
IP-0000123456
IP-000ABC0123
1/1/2022
AB12C
1234
1
IP-000ABC0123
Above is an example of the type of data I usually get, limited to only those fields that are relevant.
As you can see there are three instances of item 123A1234-123, 2 of which have no Job ID. I am trying to find a way to fill those blank spaces with the Job ID from the defect number 0 instance of the item.
The problem I am encountering is that the item code is longer on that instance. There is also the fact that listings in the item field are of several different formats, though they are mostly uniform in in format for the ones I am trying to fix.
Previous attempts at building an equation to fill the new column jobID2 result in value errors.
[#jobID2] = INDEX([jobID],MATCH(1,[countDate]=[#countDate])*([lineNumber]=[#lineNumber])*([item]=LEFT([#item],SEARCH(CHAR(164), SUBSTITUTE([#item],"-",CHAR(164),2))-1)),0))
This equation was written before I found an example in the data that didn't share the same count date.
I had help writing this but that person never replied to my follow up questions.
From what I can work out it is supposed to replace the second - with a special character and then search for that special character before returning the jobID. I think the problem is partially that not all the data matches this format, but I'm not that versed in using LEFT(SEARCH(
I am running Excel 2013 on a (8gb ram, windows 10 enterprise 64 bit, 3.1GHZ i5) machine. I've killed it a couple of times trying to run big equations on some of the data sheets so I'm unsure how complex the equation or script can be.
Any help I can get is very much appreciated.
Edit:
Current state of the equation, returns N/A on all data entries.
[#jobID2] =INDEX([jobID],MATCH(1,(([#[defectNumber]] = 0)*([lineNumber]=[#lineNumber])*(LEFT([#item],12)=LEFT([item],12))),0))
The problem I am seeing now is that
it doesn't return a row number, match just spits out 1 aka true
it doesn't look like each row is searching the whole database, just its own row
Looked up a different formula
[#jobID2] = VLOOKUP(1,CHOOSE({1,2},(LEFT([#item],12)=LEFT([item],12))*([#lineNumber]=[lineNumber])*(""<>[shopID]),[shopID]),2,0)
This returns n/a for all entries except for the ones where shopID <> 0 where it returns a 0
So... progress

Group Shared Expense Calculator using Excel

I want to track the expenses of me and my friends with excel. I have the following table structure:
Date
Amount
Paid By
Split Type
Name 1
Name 2
Name 3
...
16.05.
4.99$
Name 1
Split Equal
...
16.05.
10$
Name 1
Split Unequal by Percentage
50%
50%
...
18.05.
10$
Name 3
Split Unequal by Amount
2$
6$
2$
...
The goal is, to create a matrix-like table where you can easily read which person owes another. By using a simple excel table with big, nested formulas & try and error I was able to successfully accomplish this. However, I'm curious whether this would be doable using Pivot Tables, since they are very powerful and I always feel like "they can do everything" (and the formulas are neither nice nor easy to maintain in the future).
So for the above example, the desired result could look like this (I guess the way you get there should be pretty obvious):
Name 1
Name 2
Name 3
Name 1
-
-
0.34$
Name 2
6.66$
-
6$
Name 3
-
-
-
Question
So in short, my question is: Is there a way of creating the second table based on the first one (and maybe additional "helper" tables) using Excel's Pivot funcitonality? I would be really happy to get answers / tips for this. It would also be sufficient if you show me one case (i.e., split unequal by amount) and I'll implement the other cases based on that.
What I've tried so far
As already stated above, using a plain table I was already able to solve this task. However, the solution doesn't seem to be very elegant and thus I tried to accomplish it with by using a Pivot Table. I created one but I already struggle to get the same names in the rows & columns. If I get this working somehow, the next step would be to compute the correct values in the cells (I assume by introducing a new measure and a DAX-Formula, but I have no idea how :D)
Thanks for your help and feel free if you need more information!
Edit 1: Clarify the Result Matrix
As Jos stated, the result matrix maybe isn't that obvious unlike I throught, so I'd like to give one example:
Name 1 owes Name 3 0.34$ - why?
Name 1 pays 4.99$ and this should be split equally (thus in particular name 3 owes name 1 1.66$.
Name 1 pays 10$, however this doesn't account to name 3 since only name 1 and name 2 have to share this money
Name 3 pays 10$ from which name 1 ones him 2$, name 2 6$ and name 3 2$.
In sum, name 3 owes name 1 1.33$ from the first payment, and name 1 owes name 3 2$ from the third payment. This can be summarized by: name 3 owes name 1 1.66 $ - 2$ = -0.33$ (which is the same as saying name 1 owes name 3 0.33$

EXCEL: Match with either column

My question: Can you build a Match formula so that it matches with either column A or B?
Process is a bit convoluted but will try to make it as clear as possible; maybe someone can come up with a better way to do this that doesn't even involve an index-match formula.
I have a data set that looks something like this:
Match 1 // Team 1 // Team 2 // Winner: Team 1
Match 2 // Team 1 // Team 3 // Winner: Team 3
I want to be able to track previous performances (i.e. team results in the last 4 matches for example), to be able to use that to predict the winner. To do so, I am building a table that looks something like this:
Team 1 Match 1 // Result (0 or 1)
Team 1 Match 2 // Result (0 or 1)
Problem is, to be able to tell whether or not Team 1 played in Match 1, I need to check 2 columns and I can't find anything on using match with an OR logic (have used it with an AND logic before).
I can think of some brute force solutions (like duplicating each match so that it only has 1 team and whether or not they won), but the problem is I have 20 thousand lines of matches and hundreds of different teams, so inefficiency destroys my computer. If you see a more elegant way of doing this I am all ears!
Any thoughts?
After thinking about it for a bit, I found a way of doing it, although its not particularly elegant. The pseudo formula:
=IF(match("Team 1"; column1;0) > match("Team 1"; column2;0); index(using column2); index(using column1))
Then it is a matter of using Indirect to make the range that is being checked start after the previous matched row.

Criteria cutoffs for INDEX

I'm not even sure how to ask this so please excuse the roundabout manner forthcoming.
I have a list of tasks and would like to use =INDEX to create my array. However, there are multiple different versions of the task that could show up, and I would like to have all possible avenues covered when creating (only 4 differences).
The name of the range is TaskCode. I want to have it so I can return the first seven numbers, the period, and then only the digits directly after the period. So in case 1, I would want 0527011.3, in case 2 I would want 0527011.01, in case 3 I would want 0527011.23, and in case 4 I'd want 0527011.3.
I initially did =LEFT(TaskCode,10) but that will obviously not work in case 1 or 4. Basically I need to say cut off EITHER at the second period OR the first blank.
Thanks
=LEFT(A2,FIND("|",SUBSTITUTE(A2&".",".","|",2))-1)

Resources