In my QlikView app I made the age groups with the following expression (it is defined dimension actually)
=Replace(Aggr(Class(Count(Surname), 10), Age), '<= x <', ' - ')
The groups are calculated properly, however, I have problems with sorting the groups from the smallest to the highest one. How can I do it?
When you say that groups are calculated properly, I suppose that you mean your dimension is 0 - 10, 10 - 20...
But the value of each group is wrong.
Try something like this : =Replace(Class(Age, 10), '<= x <', ' - ')
Or better :
=if(isnull(Age),<Null>,subfield(class(Age, 10),' ',1) & ' - ' & (num(subfield(class(Age, 10),' ',5))-1))
This one handle Null and make better groups.
Class fonction return "0 <= x < 10" which should be translate 0-9 instead of 0 - 10.
Subfield(X, ' ', Y) split X by space and return the Y part.
It can be done with sorting the dimension by text.
Related
What's the best way to check if weight are between the range using the If condition?
Ex:
If textbox.text (between) value X - value Z then
You can use standard equal operators like this:
If (Val(TextBox.Text) >= ValueX) And (Val(TextBox.Text) <= ValueZ) Then
' etc...
Val function extracts numbers from string.
The autoaxis for one of my embedded charts isn't behaving well, sometimes only showing one other major value besides top and bottom. So I thought I'd set my own boundaries, which seemed pretty easy given that one of the columns on the chart is always going to be larger than any of the others.
<Maximum>=(((Max(Fields!Entered.Value, "Chart1") + 10) \ 50) + 1) * 50</Maximum>
(the other columns detail what happened to the things that entered this process)
Round up to the nearest 50 with a little overage to put the label on top. Then I can put the intervals at this divided by 5 and I'm gold.
Except I'm not gold. The chart groups records by date and the individual bars are Sum(Fields!Entered.Value) et cetera, so it's drastically underscaling when multiple batches get processed on a single date. But hey, it groups records by date, I can use that:
<ChartCategoryHierarchy>
<ChartMembers>
<ChartMember>
<Group Name="Chart1_CategoryGroup">
<GroupExpressions>
<GroupExpression>=Fields!Date.Value</GroupExpression>
</GroupExpressions>
</Group>
</ChartMember>
</ChartMembers>
</ChartCategoryHierarchy>
as:
<Maximum>=(((Max(Fields!Entered.Value, "Chart1_CategoryGroup") + 10) \ 50) + 1) * 50</Maximum>
and it'll aggregate over the group just fine. Right?
The ValueAxis_Primary.Maximum expression for the chart 'Chart1' has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a dataset.
Nope! It works just fine for "Chart1" but not for "Chart1_CategoryGroup"!
So, uh:
what scope are the axis calculations operating in, 'cause it ain't the category scope?
is there some way to provide them an aggregate scope that groups the data by date so they can do their calculations proper?
You Have To Nest The Scope
A little extra work gave me this insight:
Max(Fields!Entered.Value, "Chart1_CategoryGroup") returns the maximum of the entered fields within one single category group, which is not the level the Y axis is concerned with. What you're interested in is the maximum value of the summed calculation (within a group) for the whole chart, so specify the scopes to do that:
<Maximum>
=(((Max(
Sum(Fields!Entered.Value, "Chart1_CategoryGroup")
, "Chart1") + 10) \ 50) + 1) * 50
</Maximum>
In the documentation and all examples I can find... in terms of nurse scheduling at least, everyone just declares shift values within the search space of {1,4} lets say for shift 1,2,3,4....
solver = pywrapcp.Solver("schedule_shifts")
num_nurses = 4
num_shifts = 4 # Nurse assigned to shift 0 means not working that day.
num_days = 7
# [START]
# Create shift variables.
shifts = {}
for j in range(num_nurses):
for i in range(num_days):
shifts[(j, i)] = solver.IntVar(0, num_shifts - 1, "shifts(%i,%i)" % (j, i))
shifts_flat = [shifts[(j, i)] for j in range(num_nurses) for i in range(num_days)]
# Create nurse variables.
nurses = {}
for j in range(num_shifts):
for i in range(num_days):
nurses[(j, i)] = solver.IntVar(0, num_nurses - 1, "shift%d day%d" % (j,i))
I want to avoid the use of range of values when I call solver.IntVar(lowerbound, upperbound, ...)
I want IntSolver([available values that you can choose], ...)
I created a matrix of all shifts as the columns flowing from the first day to last. My row indexes don't matter but in each day/shift column, I have the index values of nurses in ranked descending order of who bid the highest for that shift. I want to create then a constraint where if I choose a nurse, I choose the maximum bid that is allowed via other constraints from the column, however I don't know how to do that given the limited documentation ortools has with python IntVar.
Can you try
solver.IntVar([values...], 'name')
It should work.
See https://github.com/google/or-tools/blob/master/examples/python/einav_puzzle2.py
I have a table with with one column for product dimensions.
example rows:
16" L x 22" W x 6" H
22.5" L x 12" W x 9" H
I am trying to get the length, width, and height into separate columns. I have to use SQL because this is being used in a software integration that only accepts SQL statements. I am thinking I have to go the route of regex.
SQL Statement to get the data so far
SELECT TOP 10
[ID]
,substring([SHIP_DIMENSIONS],PATINDEX('%[0-9]\"%',[SHIP_DIMENSIONS]),2) as Length
,substring([SHIP_DIMENSIONS],PATINDEX('%[0-9]\"%',[SHIP_DIMENSIONS]),2) as Width
,substring([SHIP_DIMENSIONS],PATINDEX('%[0-9]*\"%',[SHIP_DIMENSIONS]),2) as Height
FROM [PART]
I need the output to be
Length | Width | Height
16 | 22 | 6
22.5 | 12 | 9
Any suggestions would be greatly appreciated.
One way to do it is as follows:
select
left(dim, charindex('" L', dim)-1) as [Length]
, substring(dim, charindex('" L', dim)+6, charindex('" W', dim)-charindex('" L x ', dim) - 6) as [Width]
, substring(dim, charindex('" W', dim)+6, charindex('" H', dim)-charindex('" W x ', dim) - 6) as [Height]
from test
The idea is to look for the markers that you have in your text, and use them to parcel out the string into substrings. This approach is very rigid, in that it assumes that the pattern shown in your example is followed precisely in all your records, i.e. all the markers are present, along with the spaces. There is also an implicit assumption that all dimensions are in inches. What can vary is the width of the columns.
Demo.
Note: I am assuming that you are dealing with a legacy database, so there is no way to do the right thing (which is to separate out the dimensions into separate columns).
I want to generate composite sequences in the following format:
<Alphabet><2 digit numeric code>
Each alphabet series will have numeric values ranging from 00 to 99.
The initial value will be A00, the subsequent values will be A01, A02 and so on. Upon reaching A99, the next sequence should carry-on to B00. When the "B" series is exhausted, it will move over to the C-series (i.e. C00) and so on. The sequence will continue until it reaches Z99 - at which point it will reset back to A00.
How can this be done in SQL (or PL/SQL)?
Personally I would store just a NUMBER and then calculate the "composite sequence" on the fly with something like:
select
chr(ascii('A') + ((number_sequence div 100) mod 26)) || to_char(number_sequence mod 100) composite_sequence,
...
from mytable
26 assuming the English alphabet, modify for your desired alphabet
Use:
SELECT CHR(x.ascii) || LPAD(y.num - 1, 2, '0') AS val
FROM (SELECT 64 + LEVEL AS ascii
FROM DUAL
CONNECT BY LEVEL <= 26) x,
(SELECT LEVEL AS num
FROM DUAL
CONNECT BY LEVEL <= 100) y