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>
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
I want to compare two textboxes with data in a datatable and use this comparison operation to filter the datetable.
For example: I want to show all data (rows and columns) that have value x in which:
textbox1.text>x>textbox1.text
I have used "Like" operator inside string format to get the value that matches the value in the text-box completely but I could not do the required range filtering operation
Here is my code related to the specified question:
dv.RowFilter = string.Format("Type Like '%{0}%' and Gain Like" +
"'%{1}%'" +
"and Year Like'%{2}%' and MotorPower Like '%{3}%'" +
"and Profit Like '%{4}%'", textBoxType .Text,textBoxGain.Text
, textBoxYear.Text, textBoxBiggerthan.Text, textBoxKar.Text);
dataGridView1.DataSource = dv;
I have another input textbox called textBoxSmallerthan.Text
and I want to make my range for MotorPower column in datatable (datagridview) between textBoxBiggerthan.Text and textBoxSmallerthan.Text
The documentation here shows the numbers do not need be wrapped with single quote makers. So the format is:
Columnname < Number
So the final filter should be something like this:
dv.RowFilter = string.Format("Type Like '%{0}%' and Gain Like" +
"'%{1}%'" +
"and Year Like'%{2}%' and MotorPower > {3} and MotorPower < {4}" +
"and Profit Like '%{4}%'", textBoxType .Text,textBoxGain.Text
, textBoxYear.Text, textBoxSmallerthan.Text, textBoxBiggerthan.Text, textBoxKar.Text);
dataGridView1.DataSource = dv;
I understand that InterpolateRGBColors function is returning a color by position of value between 0 and 1... So its seems to be doable only with percentages, not numbers...
Is there a way to have the same functionality, but based on the min and max values returned in a set ?
What I want is to attribute colors to my measure but in a range of min([Measures].[NbSejours]) to max([Measures].[NbSejours]) ( not 0 to 1)...
WITH
MEMBER [Measures].[color] AS
InterpolateRGBColors(
[Measures].[NbSejours]
,rgb(176,224,230)
,rgb(135,206,235)
,rgb(0,191,255)
,rgb(100,149,237)
,rgb(0,0,255)
,rgb(0,0,139)
,rgb(25,25,112)
), BACK_COLOR=currentCellValue()
SELECT
{
{[Measures].[NbSejours]}
,[Measures].[color]
} ON COLUMNS
,{
NonEmpty
(
[Etablissement].[Etablissement].[Etablissement].ALLMEMBERS
,[Measures].[NbSejours]
)
} ON ROWS
FROM
(
SELECT
{{[Periode].[Periode].[All-M].&[2013]}} ON 0
FROM [Cube]
)
CELL PROPERTIES
STYLE
,CLASSNAME
,VALUE
,FORMATTED_VALUE;
Is there a way to do that ?
InterpolateRGBColors expect a numerical between 0 and 1 for interpolation. So we need to scale our measure to ensure we get the right colors.
There is an example in our live demo , here.
What we need is to scale [Measures].[NbSejours] between 0,1. There are two no documented function in icCube DistributionFlat & DistributionRank.
A non efficient version
WITH
SET [AxisX] AS NonEmpty([Etablissement].Etablissement].Etablissement].ALLMEMBERS,[Measures].[NbSejours])
FUNCTION distr(x_) as DistributionFlat( [AxisX], [Measures].[NbSejours], x_ )
MEMBER [Measures].[color] AS
InterpolateRGBColors(
distr([Measures].[NbSejours])
,rgb(176,224,230)
,rgb(135,206,235)
,rgb(0,191,255)
,rgb(100,149,237)
,rgb(0,0,255)
,rgb(0,0,139)
,rgb(25,25,112)
), BACK_COLOR=currentCellValue()
....
Once I got a bit of time I'll write a version using Vectors (here and here) that is more performant as in the example above we calculate every time the values for the set.
Hope it helps
I don'r know icCube so the following might not work, even though I have used standard functions. As #George commented you can use the standard RANK function to find each members relative position.
You will need to feed that value into the definition of [Measures].[color]...
WITH
SET [estMembersOrdered] AS
ORDER(
[Etablissement].[Etablissement].[Etablissement].ALLMEMBERS
,[Measures].[NbSejours]
,BDESC
)
MEMBER [Measures].[rnkEtablissement] AS
RANK(
[Etablissement].[Etablissement].CURRENTMEMBER
, [estMembersOrdered]
)
MEMBER [Measures].[color] AS
InterpolateRGBColors(
[Measures].[NbSejours]
,rgb(176,224,230)
,rgb(135,206,235)
,rgb(0,191,255)
,rgb(100,149,237)
,rgb(0,0,255)
,rgb(0,0,139)
,rgb(25,25,112)
), BACK_COLOR=currentCellValue()
SELECT
{
{[Measures].[NbSejours]}
,[Measures].[color]
,[Measures].[rnkEtablissement]
} ON COLUMNS
,{
NonEmpty
(
[Etablissement].[Etablissement].[Etablissement].ALLMEMBERS
,[Measures].[NbSejours]
)
} ON ROWS
FROM
(
SELECT
{{[Periode].[Periode].[All-M].&[2013]}} ON 0
FROM [Cube]
)
CELL PROPERTIES
STYLE
,CLASSNAME
,VALUE
,FORMATTED_VALUE;
I have a string field with mostly numeric values like 13.4, but some have 13.4%. I am trying to use the following expression to remove the % symbols and retain just the numeric values to convert the field to integer.
Here is what I have so far in the expression definition of Cognos 8 Report Studio:
IF(POSITION('%' IN [FIELD1]) = NULL) THEN
/*** this captures rows with valid data **/
([FIELD1])
ELSE
/** trying to remove the % sign from rows with data like this 13.4% **/
(SUBSTRING([FIELD1]), 1, POSITION('%' IN [FIELD1])))
Any hints/help is much appreciated.
An easy way to do this is to use the trim() function. The following will remove any trailing % characters:
TRIM(trailing '%',[FIELD1])
The approach you are using is feasable. However, the syntax you are using is not compatible with the version of the ReportStudio that I'm familiar with. Below you will find an updated expression which works for me.
IF ( POSITION( '%'; [FIELD1]) = 0) THEN
( [FIELD1] )
ELSE
( SUBSTRING( [FIELD1]; 1; POSITION( '%'; [FIELD1]) - 1 ) )
Since character positions in strings are 1-based in Cognos it's important to substract 1 from the position returned by POSITION(). Otherwise you would only cut off characters after the percent sign.
Another note: what you are doing here is data cleansing. It's usually more advantageous to push these chores down to a lower level of the data retrieval chain, e.g. the Data Warehouse or at least the Framework Manager model, so that at the reporting level you can use this field as numeric field directly.