stuck in replacing negative values with zero in SPSS Modeler - spss-modeler

I am trying to replace the -ve values with "0" and derive a new variable in SPSS Modeler . I am trying "Derive" node to accomplish the job using the function of "if INDV_ASS_INC_TAMT < 0 then INDV_ASS_INC_TAMT=0 else INDV_ASS_INC_TAMT=INDV_ASS_INC_TAMT endif" but getting the following error " The conditional expression contains incompatible return types: Boolean and Integer".
I am novice SPSS Modeler User and stuck for 2 days to figure it out . Your help would much appreciated .
Snap shot in link 1
[Error ][1]

Use "Filler node" to replace value in your Column based on condition.
https://www.ibm.com/support/producthub/icpdata/docs/content/SSQNUZ_current/wsd/nodes/filler.html

Related

Failed to expand block containing connect

I´m trying to set a connection with a conditional on the temperature, to represent a temperature-sensible charging pipe that works inside a stratified heat storage tank, with the following for loop reading the several volumes of the tank,
`for i in 2:nSeg loop
if (sensor_T_inflow.T > vol[i].T) and (sensor_T_inflow.T < vol[i-1].T) then
connect(feedPort, vol[i].ports[3])
annotation (Line(points={{-50,-60},{6,-60},{6,
-16},{16,-16}}, color={0,127,255}));
end if;
end for;`
However I get the errors such as this one for the volume 2:
Failed to expand block containing connect:
if (sensor_T_inflow.T > vol[2].T and sensor_T_inflow.T < vol[1].T) then connect(feedPort, vol[2].ports[3]); end if;
The model contained invalid connect statements.
Check aborted.
This might have a silly solution but I checked the names of all my elements and their temperature properties and they match with this code snippet, and I confirmed the error comes specially from the if conditional. Here is my model If you could take a look at it.
I tried commenting out the conditional and the check was succesful, only that I have a misbalance of about 40 variables to equations. If you got any advice on how to solve those misbalances I´d be much grateful as well.
Thanks a lot in advance.
The connect-statements may not depend on time-varying variables.
(The technical statement is first in the list in https://specification.modelica.org/master/connectors-and-connections.html#restrictions-of-connections-and-connectors )
A solution would be to turn that into an array of valve-components, and have them controlled in a similar way.

How to creat a chart from a value in PowerBI

When I try to create a chart from a value (Datatype : Double) PowerBI keeps considering the COUNT(myvalue) and not the value itself.
Same issue when i try to add value_from_field_A to value_from_field_B it adds COUNT(value_from_field_A) + COUNT(value_from_field_B) which gives 2 (1+1...).
Doesn't it seem natural to take the value itself instead of the count ??
What should I do?
Thanks in advance !

how to fill na with a specific value based on a condition

Still learning python, and struggling with dates and na's.. I have a situation as the image below would show
enter image description here
for the NAT values in the column EndDT_New, i would like to fill them with a specific value based on a condition, eg:
if the DATE_ACT_CLOSED = '01/01/2040' then replace just the NAT in EndDT_New with 30/03/2021 else
if the DATE_ACT_CLOSED <> '01/01/2040', then replace just the NAT in EndDT_New with the value in DATE_ACT_CLOSED .
My previous experience is in SAS, so its quite a learning curve and mind shift to python.
Any help is much appreciated.
Kind Regards,
i reckon i figured it out.
df_all_valid.loc[(np.isnat(df_all_valid['EndDT_New'])==True) & (df_all_valid['DATE_ACT_CLOSED'] == '01/01/2040'), 'EndDT_New'] = np.datetime64('2021-03-30')

How to reciprocate?

Actually I am coding a Matlab simulation where the AnchorID and SourceID will report to eachother. For example if I take an anchor 30 and source 50 it will collect all the agc values between these anchor and source and calculate rssi_dB and display them.Below mentioned is an example of anchor 30 and source id 50
Note: list of anchors ID's and source ID's are same. for e.g. 30 50 55 58 . These ID are both same for anchor and source.
function A30(BlinkSet)
for i=1:length(BlinkSet)
xAnchorID=30;
xSourceID=50;
a=BlinkSet{i}.AnchorID;
b=BlinkSet{i}.SourceID;
if xAnchorID==a && xSourceID==b
xagc=BlinkSet{i}.agc;
rssi_dB(i)=-(33+xagc*(89-33)/(29-1));
end
end
rssi_dB(rssi_dB==0)=[];
rssi_dBm=sum(rssi_dB(:))/length(rssi_dB);
disp([sprintf('The rssi value is %0.0f',rssi_dBm)]);
When I call the function in Matlab command window I get the rssi value of the above function.
Also my task is when I reciprocate the Anchor ID and source ID say Anchor as 50 and source as 30 like the function I have mentioned below I get an error which is mentioned after the function below.
function A50(BlinkSet)
for i=1:length(BlinkSet)
xAnchorID=50;
xSourceID=30;
a=BlinkSet{i}.AnchorID;
b=BlinkSet{i}.SourceID;
if xAnchorID==a && xSourceID==b
xagc=BlinkSet{i}.agc;
rssi_dB(i)=-(33+xagc*(89-33)/(29-1));
end
end
rssi_dB(rssi_dB==0)=[];
rssi_dBm=sum(rssi_dB(:))/length(rssi_dB);
disp([sprintf('The rssi value is %0.0f',rssi_dBm)]);
When I call this function I get an error as
??? Undefined function or variable "rssi_dB".
Error in ==> A50 at 14
rssi_dB(rssi_dB==0)=[];
Error in ==> main_reduced at 26
A50(BlinkSet);
In main function I have coded like this,
%A30(BlinkSet);
A50(BlinkSet);
Any help is highly appreciated.
In both of these functions, you only create the variable rssi_dB if execution enters the if statement within the loop (i.e., if xAnchorID==a && xSourceID==b is at some point true). Clearly, this code is never executed in your A50 function. Without knowing what is in BlinkSet it's a bit difficult to diagnose the exact problem, but this is the cause at least.
As a side note: it's not a good idea to create two separate functions to do this job when their code is almost identical. You should add an input argument to your function that allows it to do the job of both. In this particular case, all that changes is the value of xAnchorID and xSourceID, so you could just pass these in:
function srcToAnchorRssi(BlinkSet, xSourceID, xAnchorID)
% The rest of the function stays the same!
If you want to provide some defaults for these arguments, you can do, e.g.:
if nargin < 3 || isempty(xAnchorID), xAnchorID = 50; end
if nargin < 2 || isempty(xSourceID), xSourceID = 30; end
It's always a good idea to include an isempty in statements of this sort, so that your function supports syntax like myFunction(myArg1, [], myArg3). Also note that the order of the operands to || is crucial; if you did if isempty(theArgument) || nargin < theArgumentNumber and the user did not pass theArgument, then it would error in the isempty because theArgument would not exist as a local variable. We can get around this by swapping the operands' order because MATLAB is smart enough to know it doesn't have to evaluate the right operand if the left operand is true (note that this is also the case in many other programming languages).

Excel SUM current column (via Excel::Template)

I'm using Excel::Template to generate a series of Excel files via perl. However, I need to do a SUM function on the current Column. I know I can do
=SUM(3:15)
but that gives the sum of ALL columns in rows 3-15. Is there an easier way to do what I'm trying to do?
=sum(indirect(concatenate(address(<row_start>,column()),":")&address(<row_end>,column())))
gives me exactly what I need. Not exactly sure how it works, but found on MrExcel.com
For column C,
=SUM(C3:C15)
Since =SUM(...) is just a string, you may have to parametrize the column if you don't know it before runtime. For instance
$str = "=SUM(" . col_char . "3:" . col_char . "15)";