I have a column in my matrix table that is a varchar containing numeric values (stepName). In the report, it prints off as 1,10,11... 2,20,21,22... etc instead of 1,2.. 10, 20.
I found another question that suggested either converting the varchar values to int and then sorting, or adding a datatype numeric column and using that to sort. (sorting string numeric values in SSRS 2008)
I can't convert the varchar values to int as I have about 50/50 varchar/numeric values. I actually have a numeric sequence column, but when I tried to use this as a sort both in the query, the column tablix properties and the list tablix properties, it still didn't sort. What am I missing? Thank you!
select hrss.salaryScheduleCode, hrss.salaryScheduleName, st.stepName, st.seq, sl.laneName
from dbo.HRSalarySchedule hrss
left join dbo.HRSalaryScheduleStep st on st.hrSalaryScheduleID = hrss.hrSalaryScheduleID
left join dbo.HRSalaryScheduleLane sl on sl.hrSalaryScheduleID = hrss.hrSalaryScheduleID
order by hrss.salaryScheduleCode, st.seq, sl.seq
Change the sorting of the tablix to use an expression:
=CInt(Fields!stepName.Value)
Edit:
Ok, I misunderstood the 50/50 thing with varchar/numeric values, so here's a better solution.
The Val function evaluates a leading numerical value, so I suggest to create 2 sorting columns:
Expression =Val(Fields!stepName.Value)
Field stepName
This will for example create a sort order like this:
Here's a screenshot to clarify what to configure:
Related
I have the following matrix loaded:
I need to change the font color of the BB column values when the value is below the value contained in the MIN column cell.
Being grouped columns, the MIN column will not always be in fourth place. How can I do to compare values taking into account the name of the columns?
Thank you!!
I share the output of the dataset:
I have found a solution based on our discussion in the comments:
Create a calculated field in your dataset Ref = ELEMENT + COMPONENT (concatenate the 2 colums, this will be used later)
In the Row Group properties, add a variable MinVar =lookup("MIN" & Fields!Component.Value ,Fields!Ref.Value,Fields!Value.Value,"DataSet1") (replace DataSet1 with your dataset name)
In the font expression of the value field add an expression =if(Fields!Element.Value ="BB",if(Me.Value< Variables!MinVar.value,"Red","Black") ,"Black")
I have tested this and it is working on my end.
I want to count the occurrences of values in a column. In my case the value I want to count is TRUE().
Lets say my table is called Table and has two columns:
boolean value
TRUE() A
FALSE() B
TRUE() A
TRUE() B
All solutions I found so far are like this:
count_true = COUNTROWS(FILTER(Table, Table[boolean] = TRUE()))
The problem is that I still want the visual (card), that displays the measure, to consider the filters (coming from the slicers) to reduce the table. So if I have a slicer that is set to value = A, the card with the count_true measure should show 2 and not 3.
As far as I understand the FILTER function always overwrites the visuals filter context.
To further explain my intent: At an earlier point the TRUE/FALSE column had the values 1/0 and I could achieve my goal by just using the SUM function that does not specify a filter context and just acts within the visuals filter context.
I think the DAX you gave should work as long as it's a measure, not a calculated column. (Calculated columns cannot read filter context from the report.)
When evaluating the measure,
count_true = COUNTROWS ( FILTER ( Table, Table[boolean] = TRUE() ) )
the first argument inside FILTER is not necessarily the full table but that table already filtered by the local filter context (including report/page/visual filters along with slicer selections and local context from e.g. rows/column a matrix visual).
So if you select Value = "A" via slicer, then the table in FILTER is already filtered to only include "A" values.
I do not know for sure if this will fix your problem but it is more efficient dax in my opinion:
count_true = CALCULATE(COUNTROWS(Table), Table[boolean])
If you still have the issue after changing your measure to use this format, you may have an underlying issue with the model. There is also the function KEEPFILTERS that may apply here but I think using KEEPFILTERS is overcomplicating your case.
I have a clickhouse table that has one Array(UInt16) column. I want to be able to filter results from this table to only get rows where the values in the array column are above a threshold value. I've been trying to achieve this using some of the array functions (arrayFilter and arrayExists) but I'm not familiar enough with the SQL/Clickhouse query syntax to get this working.
I've created the table using:
CREATE TABLE IF NOT EXISTS ArrayTest (
date Date,
sessionSecond UInt16,
distance Array(UInt16)
) Engine = MergeTree(date, (date, sessionSecond), 8192);
Where the distance values will be distances from a certain point at a certain amount of seconds (sessionSecond) after the date. I've added some sample values so the table looks like the following:
Now I want to get all rows which contain distances greater than 7. I found the array operators documentation here and tried the arrayExists function but it's not working how I'd expect. From the documentation, it says that this function "Returns 1 if there is at least one element in 'arr' for which 'func' returns something other than 0. Otherwise, it returns 0". But when I run the query below I get three zeros returned where I should get a 0 and two ones:
SELECT arrayExists(
val -> val > 7,
arrayEnumerate(distance))
FROM ArrayTest;
Eventually I want to perform this select and then join it with the table contents to only return rows that have an exists = 1 but I need this first step to work before that. Am I using the arrayExists wrong? What I found more confusing is that when I change the comparison value to 2 I get all 1s back. Can this kind of filtering be achieved using the array functions?
Thanks
You can use arrayExists in the WHERE clause.
SELECT *
FROM ArrayTest
WHERE arrayExists(x -> x > 7, distance) = 1;
Another way is to use ARRAY JOIN, if you need to know which values is greater than 7:
SELECT d, distance, sessionSecond
FROM ArrayTest
ARRAY JOIN distance as d
WHERE d > 7
I think the reason why you get 3 zeros is that arrayEnumerate enumerates over the array indexes not array values, and since none of your rows have more than 7 elements arrayEnumerates results in 0 for all the rows.
To make this work,
SELECT arrayExists(
val -> distance[val] > 7,
arrayEnumerate(distance))
FROM ArrayTest;
I'm having trouble using XPath to find a row in a table where a specific column contains a value. The table has 10 columns where 2 of them will show Yes|No but I'm only interested in finding the value in one of the columns (the 4th one). My initial attempt was this:
//table[#id='myTable']/tbody/tr/td[text() = 'Yes']
but it finds it rows from both columns. I thought I could try something like this but it's not a valid expression:
//table[#id='myTable']/tbody/tr/td[4]/text()='Yes'
Any suggestions? Thanks.
You can try this way :
//table[#id='myTable']/tbody/tr[td[4][. = 'Yes']]
The XPath return row (tr) having the forth td child value equals "Yes".
I would like to apply natural number sort order to the attribute representing members' age, but including sub zero values and empty values in addition to the natural human age.
I would like to know whether label column accepts such sub zero values or empty values inevitably flown into from the manually input source data like logs.
Yes!
You have to change the data type of the label from Varchar(128) to Integer.
There are two ways to do it:
run MAQL: "ALTER DATATYPE {f_dataset_name.nm_label_name} INT;"
Go to CloudConnect LDM modeler. Click on Dataset => Edit => Show
DataTypes => change datatype on label to Integer
This data type accepts also sub zero values. For "null" or "empty" values there has to be upper case null string "NULL" in the source data.