Update a column value based on another column value with SubSonic 2.1/2.2 - subsonic

I have the following code using SubSonic 2.1/2.2
SubSonic.Update(<some table>)
.Set(<column A>)
.EqualTo(<column B>).
Where(condition...).Execute()
I would like to change it to update "column A" with the value of "column B" + 1.
How can I do it with this syntax.
Is there a better SubSonic syntax to achieve the same thing:
ColumnA = ColumnB + 1
Or even
ColumnA = ColumnA + a

Using SetExpression instead of Set will solve the problem
SubSonic.Update(<some table>)
.SetExpression("columnA")
.EqualTo("columnB + 1").
Where(condition...).Execute()

Related

Is it possible to show steps of calculation in Excel?

Let's say for example that I have these number in diffetent cells : 5 , 3 , 2. In different cell I type "=SUM(cells of my numbers)". So my question is : is it possible that result will be shown as "5 + 3 + 2" instead of just "10"?
BTW: I know that it's rather strange question.
You can use TEXTJOIN
=TEXTJOIN(" + ",TRUE,A1:C1)&" = "&SUM(A1:C1)
As mentioned via comment & assuming A1:A3 contain the desired value, the formula :
=A1&" + "&A2&" + "&A3
should do what you need. It is not a strange question. Maybe the (technically closer) is it possible that cell to display.. term is closer to what the technical communities here have in mind. (I'm not complaining.. english is hard on me too).
*Just fyi, "show calculation step" is the use of [ (select cell with formula) > Formula > Evaluate ] function in excel. It may be the reason this question is misunderstood. (^_^)\

switch function Excel

I am working on an Excel switch funciton but something is not working.
I have 2 tables. This is my table 1 -
And this is my Table 2 -
Now, what is want is - when the table 1 "Pick value" Column has a value of A it should enter code herepick the value from Table 2 column value A Value when the value is B, it should pick B Value, else C value from the corresponding field.
That IS WHY I am using this switch query in Excel -
=SWITCH([Pick Value];"A";Table2[A Value];"B";Table2[B Value];Table2[C Value];)
But it is not working -
Anyone knows what I am doing wrong here!
Here is a SWITCH version also using XLOOKUP:
=XLOOKUP([#ID];Table2[ID];SWITCH([#[Pick Value]];"A";Table2[A Value];"B";Table2[B Value];"C";Table2[C Value]))
Use FILTER:
=#FILTER(CHOOSE(MATCH([#Pick Value];{"A";"B";"C"};0);Table2[A Value];Table2[B Value];Table2[C Value]);Table2[ID]=[#ID])
INDEX/MATCH
If you don't have 365, you can use one of the following formulas.
Comma
Array formula (CRTL+SHIFT+ENTER):
=IFERROR(INDEX(Table2[#[A Value]:[C Value]],MATCH([#[Pick Value]],LEFT(Table2[[#Headers],[A Value]:[C Value]],1),0)),"")
or if using "A","B","C" explicitly (ENTER):
=IFERROR(INDEX(Table2[#[A Value]:[C Value]],MATCH([#[Pick Value]],{"A","B","C"},0)),"")
Semi Colon
Array formula (CRTL+SHIFT+ENTER):
=IFERROR(INDEX(Table2[#[A Value]:[C Value]];MATCH([#[Pick Value]];LEFT(Table2[[#Headers];[A Value]:[C Value]];1);0));"")
or if using "A","B","C" explicitly (ENTER):
=IFERROR(INDEX(Table2[#[A Value]:[C Value]];MATCH([#[Pick Value]];{"A";"B";"C"};0));"")

How can I produce this as a new column in an alteryx table?

Each row needs to be paired up with the one before it therefore I need a new column that looks like the following.
flag
1
1
2
2
3
3
4
4
5
5
.
.
.
and so on
You can solve this a number of ways with Alteryx. I chose to use one tool, the Multi-Row Formula tool, to make an elegant solution.
Add the Multi-Row Formula tool.
Use the default "Create a New Field" option and name the field "flag".
Choose 2 as the "Num Rows".
Choose "NULL" as the "Values for Rows that don't Exist".
For the expression, paste the following:
IF ISNULL([Row-1:flag])
THEN 1
ELSEIF [Row-1:flag] == [Row-2:flag]
THEN [Row-1:flag] + 1
ELSE [Row-1:flag]
ENDIF
This will create the flag for you by paring the first and second rows, third and fourth, and so on.
As a reference, see my page in the Alteryx community. I am a certified partner.
Alteryx Reference

countif excel with value in column A or column B

I want to use COUNTIF in Excel, but I want to count rows where column V = yes OR column U = yes, with all the other criteria the same.
It is easy to use or with values in 1 column, such as P4:P999 = "apple" or "orange", but how to use or over multiple columns?
Below is an Excel code sample written to be readable. The only solution I found was to use addition and rewrite the entire code, but I hate this solution because it is too long.
SUM(COUNTIFS(
P4:P9999, {"apple", "orange"},
B4:B9999, "potato",
AF4:AF9999, "",
V4:V9999, "Yes"
)
) +
SUM(COUNTIFS(
P4:P9999, {"apple", "orange"},
B4:B9999, "potato",
AF4:AF9999, "",
U4:U9999, "Yes"
)
)
Switch to SUMPRODUCT:
=SUMPRODUCT(((P4:P9999 = "apple")+(P4:P9999 = "orange"))*(B4:B999="potato")*(LEN(AF4:AF999)=0)*((V4:V9999="Yes)+(U4:U9999="Yes")>0))

(Excel 2013/Non-VBA) Format Data column based on value of another cell?

We have a column that is query driven, and the query partially formats the values in the column using math based off the value of a "user entry cell" on another sheet.
For the really curious, our query looks like this:
DECLARE #rotationsNum INT
SET #rotationsNum = ?
SELECT t.Piece_ID, t.Linear_Location, ((ROW_NUMBER() OVER(ORDER BY
Linear_Location) -1 )%#rotationsNum )*(360/#rotationsNum) AS Rotation FROM
(SELECT Position.Feature_Key, Piece_ID, ((Place-1)%(Places/#rotationsNum))+1 AS Linear_Location, Place, Measured_Value, Places FROM Fake.dbo.Position LEFT JOIN Fake.dbo.Features
ON Position.Feature_Key = Features.Feature_Key WHERE Position.Inspection_Key_FK = (SELECT Inspection_Key FROM Fake.dbo.Inspection WHERE Op_Key = ?)) AS t
ORDER BY Piece_ID, Linear_Location
The first parameter "#rotationsNum" is a cell that will always have a value between 1-4. IF the value is 1, the entire column will show "0"s, which we want to show as "N/A". However, it isn't as simple as "How to hide zero data.." Because if the "#rotationsNum" == 2, 3, or 4, there will still be 0 values in the column that need to be shown.
A "#rotationsNum" value of 2 will have the query write the column as such: example
So I am trying to come up with a way to format the column =IF(cell>1, do nothing, overwrite entire column to say "NA"). But I don't think it is that straight forward since the column is query driven.
My resolution was to format the column so that if the cell that drives the "#rotationsNum" parameter is below 2, then the whole column just gets "grayed out". It kind of makes it look like a redaction, and isn't as desirable as "NA", but it works for our purposes. Hopefully this solution helps someone else who stumbles upon this problem.

Resources