How to sort a text containing numbers by numbers' values? - pega

I have got a repeat layout with the several columns. One of them prints data as "123 days", so it is Text.
When I try to order rows by the column, I get something like: "121 days", "122 days", "123 days", "13 days", "124 days".
A property of the column is contained in the Data Base as Integer, but there is an activity, which converts it into Text adding "days".
I suppose that the solution of the issue is utilizing Number despite of Text, but displaying "days" is a business requirement and I am
not able to just throw it out.
Are there any workarounds to display "days" and to order the column as Number?
Thank you.

Yes, there is a workaround. You need to create your own Control rule to display Number + "days".
Don't append days through the activity. Keep numbers as it is. You must be using Text Input control to display the property.
Create you own control. Uncheck the Auto-Generated? check box from HTML tab.
In the code part write this.
<%= tools.getActiveValue() %> days
Thats it.

Related

how to get a column of a rhandsontable to round to and display only whole numbers?

So something like:
format="0,0.00"
will always round and display 2 decimal places.
What is the pattern that I need to assign to format in order to get it to display only whole numbers?
Use format = '0a', you can see the whole documentation here.

Remove total value for one column in PowerBI

I have a table visualisation in PowerBI that sums the top 10 products sold by sales quantity. I have a calculated column which shows the rate of sale, using other fields from the data source:
(quantity / # stores with product) / weeks on sale
The ROS calculates correctly, but it still sums and appears in the total row.. The number of stores and number of weeks are set to 'Don't Summarize', but they still add together and give some meaningless number in the total row. If i set ROS to 'Don't Summarize', to remove the total row, the summing of the rest of the table and therefore the filter I have on top N by quantity drops out.
It is very frustrating! Is there an option somewhere to simply not display total for a field?? I don't want to remove the total row completely as the other fields (e.g. Qty, Value, Margin) are useful to see a sum of.. It seems very strange that it is so difficult to do something so minor..
Additional info:
Qty is a SUM field.
Stores is not summarized and simply refers to the average number of stores that stock that product over the weeks of the trading season
Weeks is not summarized.
Weeks is not summarized and refers to the weeks that have passed in the trading season.
Example data:
Item.......Qty......Stores.....Weeks....ROS
Itm1........600........390.........2............0.77
Itm2........444........461.........2............0.48
Itm3........348........440.........2............0.40
Total.....1,392.....1,291*......6*...........1.65*
Fields marked with a * are those where the sum is a meaningless figure unrelated to the data. I do not actually need Stores and Weeks to show in the table, so the fact that they sum does not matter. However, ROS is essential, but the sum part is totally irrelevant and I do not want it to show. Any ideas? I am open to the idea of using R to overcome the lack of flexibility in the standard tables although my knowledge in this area is fairly limited.
I suspect you've made a common mistake - using a Calculated Column for ROS where you should've used a Measure.
If you rebuild that calculation as a Measure, then you can wrap the HASONEVALUE function around it, with the objective of showing a blank when there are multiple Item values in context (the Total row).
Roughly the Measure formula would be:
ROS = IF ( HASONEVALUE ( Mytable[Item] ) , << calculation >> , BLANK() )
I would also replace your use of / with the DIVIDE function, to avoid divide by zero errors.
You can remove individual totals for columns in tables and matrix objects in a round-about way by using field formatting.
Click the object, go to formatting, click the field formatting accordion, select the column or columns you want to affect from the drop-down list, set the font color to white, set 'apply to values' to off, and set 'apply to totals' to on.
A bit tedious if you have many columns, but you will have, in affect, whited-out the column totals.
Heads up, you might still have a problem with exporting data, though.
Cheers
Click on the table -> Fields -> expand the value field you don't want to include -> Select "Don't Summarize." This will exclude it from the "Total" row.
select do not summarise option for those metrics which you dont want total
Select the table you want to change
In the Visualizations pane:
Go to Format,
Find the Field Formatting option,
Choose the field you don't want to summarize.
Turn off 'apply to header',
Turn off 'apply to values',
Turn ON 'apply to total',
Change the font color to white.

R Dataframe - add a newline or whitespace bewtween two strings

I have a data frame containing two columns, let's call them "description" and "closure_notes". Basically what I am trying to do is combine the contents of both of those columns into a single one (replacing the contents of "description" with the merged contents of the two). The trick is, I need there to a blank line or two between the two pieces of data.
For instances, if df$description is, "A short descriptions of the issue", and df$closure_notes is, "Solved (Workaround): Fixed issue by restarting services", then the result I want as the new value for df$description should be:
A short description of the issue
Solved (Workaround): Fixed issue by restarting services
The reason for the space is for readability. This data will be eventually shown in a shiny app and an accompanying PDF report that can be generated vi knitr/rmarkdown. I want the space in there so when someone reads this they can easily jump right to the closure notes if they want to, but they want them combined into a single column. I have tried paste with several "\n\n" as a separator, tried using writeLines and cat, which work great, printing to the screen, but I want something that will write the result back to the data frame. I am looping through each row combining these two columns, I just need that blank line separating the two pieces of data. Any suggestions? Thanks in advance!
Shiny deals with HTML tags. Therefore try using < /br> and not \n\n

Formatting number output of sliderInput in shiny

A good example of my question is found in the Movie Review example in the Shiny Gallery here:
http://shiny.rstudio.com/gallery/movie-explorer.html
There is a slider on the left hand side panel called "Year Released" which ranges between 1940 and 2014.
Here is the code for it from the ui.R
sliderInput("year", "Year released", 1940, 2014, value = c(1970, 2014))
You will notice that the formatting of the years when you use the slider are of the form:
"1,940" "2,014" with a comma separating the first digit from the last three.
I know that one can use dateRangeInputin Shiny but this requires the variable to be in a date format. For data variables that are simply numbers referring to years such as this example, is there a simple way to format the number output to remove the comma? I can't seem to figure this out, something that seems simple.
More recent releases of shiny throw the following error if one uses a format argument:
The format argument to sliderInput is deprecated. Use sep, pre,
and post instead. (Last used in version 0.10.2.2)
Now the preferred argument is evidently sep = ""
NOTE: This answer was written for older versions of shiny. If you are using version 0.11 or higher consult #duhaime 's answer instead.
In the sliderInput add a format="####" argument. That will remove the comma.
While it would not make sense for years, you can also use the format argument to do things like control how decimals are displayed.# indicates a number should be shown when present and 0 indicates a number should be shown if present and a 0 will be shown if it is absent.
For example "####.00" will show number with two decimal places, no comma, but will not show the thousands place if it is not there. With this format the number 32.6 would appear as 32.60.

Using Dates in SQLite

I have a TEXT column called "time" in a table meal and in a table pain which is TEXT formatted as YYYY-MM-DDTHH:MM. I'm trying to search for other times that are within 12 hours of a given time, although I can't figure out how to do that.
I've tried testing
WHERE pain.time < meal.time + "1:00" AND pain.time > meal.time
but this approach alters the year instead of the hour. I also tried testing the same query adding "0000-00-00T01:00", but it doesn't seem to do anything.
I'm not sure what else to test.
SQLite has no built-in date/time data type, so you have to use either numbers or strings and handle them correctly.
To do calculations, you have to either do them directly on the numerical value (which might require conversions into a number and back), or use the modifiers of the built-in date/time functions:
... WHERE meal.time BETWEEN datetime(pain.time, '-12 hours') AND pain.time

Resources