Can nested LookUp be done? - sharepoint

Hi again dear stackoverflowers!
I have one column in Sharepoint for an ID number (say that the number is 29) and another column that for that ID holds different subIDs (29.1, 29.2, 29.3, etc.).
What I need is that my PowerApp looks up into the Sharepoint list and takes the maximum subID number associated with the ID given, and automatically sums 0.1, because I do not want people to introduce two equal subIDs.
I'll give you the formula I tried (but the problem is that StartsWith is for text and Max is for numbers), so if you have any ideas about how can it be solved or you have any function that works with both text and numbers I would really appreciate it:
LookUp(my_list.'Prueba', StartsWith('Prueba' , DataCardValue9_2.Text), Max('Prueba')+0.1)
Another thing I tried was to nest LookUp functions, but that did not work either, do you know if that can be done?
LookUp(my_list, Prueba = DataCardValue9_2.Text + 0.3 , Max(Prueba) + 0.1) & LookUp(my_list, Prueba = DataCardValue9_2.Text + 0.2 , Max(Prueba) + 0.1) & LookUp(my_list, Prueba = DataCardValue9_2.Text + 0.1 , Max(Prueba) + 0.1)
Thank you very much for your time and help.

You must convert your column to a number datatype. Value() function for number.
Please do check this link: https://learn.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-value

Related

How to save decimal heights in MongoDB

I'm facing this strange problem while saving numeric values in mongodb.
I'm saving height of people in mongodb as Number, so a person with height of 5'.1" is saved as 5.1 and a person with a height of 5'.10" is also saved as 5.1.
I can't change it to string because I have a my search query based on number, ("height" : {"$gte": req.body.height.minimum_height, "$lte": req.body.height.maximum_height}).
I'm sure there must be a way to save specific values to deal with monetary transactions, but I'm not sure how to do it in my scenario.
Any suggestions are welcome !!
Since the height is already a number, it would be better to treat it in metric units and follow the convention that it represents height in centimetres.
When retrieving heights then as #J.F. suggested in the comment it can be formatted in the client app or wherever else it is required.
When storing heights it can be converted to centimetres.
For example 5'10'' becomes (5 x 12 + 10) x 2.54 = 177.8
One solution is to use two fields: the numeric value and the display value.
For 5' 10", the numeric value is 5 + 10/12 which is 5.83333...
irb(main):001:0> 5+(10/12.0)
=> 5.833333333333333
Then use the numeric field for searches and calculations and keep 5' 10" in the display field for rendering to users.
Alternatively you can only store the numeric value and calculate the display value:
irb(main):007:0> i = (5.833333333333333 * 12).round; f = i / 12; i = i % 12
=> 10
irb(main):008:0> f
=> 5
irb(main):009:0> i
=> 10
irb(main):010:0> "#{f}' #{i}\""
=> "5' 10\""
irb(main):011:0>

MATLAB: Count string occurrences in table columns

I'm trying to find the amount of words in this table:
Download Table here: http://www.mediafire.com/file/m81vtdo6bdd7bw8/Table_RandomInfoMiddle.mat/file
Words are indicated by the "Type" criteria, being "letters". The key thing to notice is that not everything in the table is a word, and that the entry "" registers as a word. In other words I need to determine the amount of words, by only counting "letters", except if it is a "missing".
Here is my attempt (Yet unsuccessful - Notice the two mentions of "Problem area"):
for col=1:size(Table_RandomInfoMiddle,2)
column_name = sprintf('Words count for column %d',col);
MiddleWordsType_table.(column_name) = nnz(ismember(Table_RandomInfoMiddle(:,col).Variables,{'letters'}));
MiddleWordsExclusionType_table.(column_name) = nnz(ismember(Table_RandomInfoMiddle(:,col).Variables,{'<missing>'})); %Problem area
end
%Call data from table
MiddleWordsType = table2array(MiddleWordsType_table);
MiddleWordsExclusionType = table2array(MiddleWordsExclusionType_table); %Problem area
%Take out zeros where "Type" was
MiddleWordsTotal_Nr = MiddleWordsType(MiddleWordsType~=0);
MiddleWordsExclusionTotal_Nr = MiddleWordsExclusionType(MiddleWordsExclusionType~=0);
%Final answer
FinalMiddleWordsTotal_Nr = MiddleWordsTotal_Nr-MiddleWordsExclusionTotal_Nr;
Any help will be appreciated. Thank you!
You can get the unique values from column 1 when column 2 satisfies some condition using
MiddleWordsType = numel( unique( ...
Table_RandomInfoMiddle{ismember(Table_RandomInfoMiddle{:,2}, 'letters'), 1} ) );
<missing> is a keyword in a categorical array, not literally the string "<missing>". That's why it appears blue and italicised in the workspace. If you want to check specifically for missing values, you can use this instead of ismember:
ismissing( Table_RandomInfoMiddle{:,1} )

Using a nested IF statement to simulate battery but need to compute actual values not comments

Trying to come up with a nested IF statement that works within a specified limit (battery state of charge) taking the necessary inputs over time.
[Sample Data Sheet]
My attempt to formulate for the State of charge operation is given below
= IF(AND(D5+A6-B6>=0.2*$G$1, D5+A6-B6<=0.95*$G$1), D5+A6-B6,0)
= IF(AND(D5+A6-B6<0.2*$G$1), D6= 0.2*$G$1+(D5+A6-B6).
= IF(AND(D5+A6-B6>0.95*$G$1), D6= 0.95*$G$1.
=IF(D5+A6-B6<=0.2*$G$1), 0.2*$G$1+(D5+A6-B6), IF(AND(D5+A6-B6>=0.2*$G$1, D5+A6-B6<=0.95*$G$1), D5+A6-B6,0), IF(D5+A6-B6>=0.95*$G$1), 0.95*$G$1)))
=IF(D5+A6-B6>=0.95*$G$1), 0.95*$G$1, IF(AND(D5+A6-B6>=0.2*$G$1, D5+A6-B6<=0.95*$G$1), D5+A6-B6,0), IF(D5+A6-B6<=0.2*$G$1), 0.2*$G$1+D5+A6-B6)))
I keep getting errors that my formulae are incorrect, please help for both state of charge and spare generation equations.
Thanks
Below is the link to the sample sheet that I have created.
https://drive.google.com/file/d/1kmhkBybMg18Odrow5jElcEt8RcLXqCFH/view?usp=sharing
I'm Assuming the G1 value is 1 or more than 1. Also, I'm also assuming the formula is for E5 cell. Here is the proposed solution.
=IF((D5+A6-B6)<(0.2*$G$1),(0.2*$G$1)+(D5+A6-B6),IF((D5+A6-B6)>(0.95*$G$1), (0.95*$G$1), IF(AND((D5+A6-B6)>=(0.2*$G$1), (D5+A6-B6)<=(0.95*$G$1)), (D5+A6-B6),"not in range")))
Here is the same equation expanded ( to see the logic and sequence ) :
=IF((D5+A6-B6)<(0.2*$G$1) , (0.2*$G$1)+(D5+A6-B6),
IF((D5+A6-B6)>(0.95*$G$1) , (0.95*$G$1),
IF(AND( (D5+A6-B6)>=(0.2*$G$1),(D5+A6-B6)<=(0.95*$G$1)) , (D5+A6-B6),"not in range"
)
)
)
Please have a check.

Query a range in an Excel table linked to PowerApps Text Search box

First time asking a question here. As well as being pretty new to PowerApps as well.
I am trying to use two text input boxes for the user to define the min & max of their number range. basically i want the code to return all results that fall in the user defined range.
User inputs are:
SearchText.Text
MinSearch.Text and
MaxSearch.Text
PDFData is the table, and
RMANumber is the column that i want the Min & Max to search and return all within the user defined range. as of now, all i can get this to return are exact results, which just won't work for my situation. In my way of thinking, i want to add WHERE after the RAWidth and give greater or lesser arguments, but this isn't working for me. My full code is below, and any help is appreciated.
If(SearchText.Text="" && MinSearch.Text="" && MaxSearch.Text="", PDFData, Filter(PDFData,SearchText.Text in PDFAuthor|| SearchText.Text in PDFName|| SearchText.Text in RMANumber|| MinSearch.Text in RAWidth))
You can use the following expression for your query:
Filter(
PDFData,
SearchText.Text in PDFAuthor || SearchText.Text in PDFName,
Coalesce(Value(MinSearch.Text), -1) <= RAWidth,
Coalesce(Value(MaxSearch.Text), 1000000000) >= RAWidth)
If the SearchText is empty, then the conditions SearchText.Text in PDFAuthor and SearchText.Text in PDFName will both be true anyway, so there's no need for the If at that point.
For the other conditions, we can use the functions Value / Coalesce to convert the text input to a number; if the user didn't enter anything (or entered an invalid number), then the function Value will return a blank value, and the Coalesce function will use the next value. I'm using here -1 for the minumum value and 1000000000 for the maximum - if the possible range of values in your RAWidth column is between those numbers then you're fine.

Converting Excel functions into R

I have two excel functions that I am trying to convert into R:
numberShares
=IF(AND(N213="BOH",N212="BOH")=TRUE,P212,IF(AND(N213="BOH",N212="Sell")=TRUE,ROUNDDOWN(Q212/C213,0),0))
marketValue
=IF(AND(N212="BOH",N213="BOH")=TRUE,C213*P212,IF(AND(N212="Sell",N213="Sell")=TRUE,Q212,IF(AND(N212="BOH",N213="Sell")=TRUE,P212*C213,IF(AND(N212="Sell",N213="BOH")=TRUE,Q212))))
The cells that are referenced include:
c = closing price of a stock
n = position values of either "buy or hold" or "sell"
p = number of Shares
q = market value, assuming $10,000 initial equity (number of shares*closing price)
and the tops of the two output columns that i am trying to recreate look like this:
output
So far, in R I have constructed a dataframe with the necessary four columns:
data.frame
I just don't know how to write the functions that will populate the number of shares and market value columns. For loops? ifelse?
Again, thank you!!
Covert the AND()'s to infix "&"; the "=" to "=="; and the IF's to ifelse() and you are halfway there. The problem will be in converting your cell references to array or matrix references, and for that task we would have needed a better description of the data layout:
numberShares <-
ifelse( N213=="BOH" & N212=="BOH",
#Perhaps PosVal[213] == "BOH" & PosVal[212] == "BOH"
# ... and very possibly the 213 should be 213:240 and the 212 should be 212:239
P212,
ifelse( N213=="BOH" & N212=="Sell" ,
round(Q212/C213, digits=0),
0))
(You seem to be returning incommensurate values which seems preeety questionable.) Assuming this is correct code despite my misgivings the next translation involves apply the same substitutions in this structure (although you seem to be missing an else-consequent in the last IF function:
marketValue <-
IF( AND(N212="BOH", N213="BOH")=TRUE,
C213*P212,
IF(AND(N212="Sell",N213="Sell")=TRUE,
Q212,
IF( AND(N212="BOH",N213="Sell")=TRUE,
P212*C213,
IF(AND(N212="Sell",N213="BOH")=TRUE,
Q212))))
(Your testing for AND( .,.)=TRUE is I believe unnecessary in Excel and certainly unnecessary in R.)

Resources