In my placeholder expression, I looking to pull multiple values from a dataset variable which relate to the parameter multiple selected values. My parameter labels are locations (Location 1, Location 2, Location 3, etc...) and the parameter values are IDs (ID1, ID2, ID3, etc...). In my dataset, I have abbreviated versions of the locations which is what I want to display in my SSRS report (Loc 1, Loc 2, Loc 3).
I would like the values to be separated by a comma.
I know I can get the parameter labels with this code:
=Join(Parameters!ParameterName.Label, ",")
So I tried something similar such as:
=Join((Fields!ABBREV.Value, ", "), "Dataset1")
and
=Join((Fields!ABBREV.Value,"Dataset1"), ", "), )
but neither worked
In the end, I would like to see the list of abbreviated locations. For example, if the user selects Location 5, Location 7 and Location 9 in the parameter, my expression should show:
loc 5, loc 7, loc 9
What is the right expression for this? Thanks in advance.
EDIT SOLUTION:
This worked...
=JOIN(MULTILOOKUP(Parameters!ParameterName.Value, Fields!ID.Value, Fields!ABBREV.Value, "DataSet1"), ", ")
I think it will work if you use LOOKUPSET.
=JOIN(LOOKUPSET(1, 1, Fields!ABBREV.Value, "DataSet1"), ", ")
Using 1 for the LOOKUP fields will return all records in Dataset1.
Related
I have column with values like:
Test
test 1
test 2
test 3
test 4
I am trying to put the values in a report in Microsoft Report Builder, but I don't want it listed in a table. I would like it to be listed like below in a text box:
test 1, test 2, test 3, test 4
Is there an expression I can use? I have looked and tried Join and Split but haven't gotten the results I am looking for.
You can do this quite easily using LOOKUPSET() to get the values into an array and then using JOIN() to combine them into a string.
=Join(LookupSet(1, 1, Fields!myTestCol.Value, "DataSet1"), ", ")
As we want all the rows from the dataset, I've used 1 in the first 2 arguments as a shortcut as 1 always equals 1 , every row in "DataSet1" will be returned. Then we JOIN() them with ", " as the separator.
Note: "DataSet1" is the case-sensitive name of your dataset. You need to change this to match your dataset name or scope name (i.e. a RowGroup name) as required.
i would like to perform Mysql search & replace with random characters, taken from a list. I cannot use regex, since my version is way prior to 8.
instead of the below,
i would like to change for instance the letter u with one out of (a,e,i,f,k) randomly.
UPDATE products
SET
productDescription = REPLACE(productDescription,
'abuot',
'about');
Is there a mysql command for this task?
Actually my goal is to get in the lastnames column, new names that are not exactly like the real ones, so one could work on "anonymous" data.
I would like to replace all rows in a certain column. Say in table products, in column description, we have data like:
abcud
ieruie
kjuklkllu
uiervfd
With the replace function, we would not want to create something like: replace e with i,
but replace e with one of (a,e,i,f,k)
example desired output:
abced
ierfie
kjiklkllk
aiervfd
like i said, we plan to use this into last names, we plan to replace many characters with random ones from a list, in an effort to create anonymous data in the column that contains last names.
On a next step, i would like to do the same, in order to make anonymous telephone numbers.
example
726456273
827364878
347823472
replace 3 with one of 0-9,
output:
726456279
827664878
547821472
SELECT REPLACE('product abuot Description',
SUBSTRING('product abuot Description', CHARINDEX('abuot', 'product abuot Description') ,5) , 'about')
CREATE FUNCTION smart_replace ( argument TEXT,
search_for CHAR(1),
replace_with TEXT )
RETURNS TEXT
NO SQL
BEGIN
SET argument = REPLACE(argument, search_for, CHAR(0));
REPEAT
SET argument = CONCAT( SUBSTRING_INDEX(argument, CHAR(0), 1),
SUBSTRING(replace_with FROM CEIL(RAND() * LENGTH(replace_with)) FOR 1),
SUBSTRING(argument FROM 2 + LENGTH(SUBSTRING_INDEX(argument, CHAR(0), 1))));
UNTIL NOT LOCATE(CHAR(0), argument) END REPEAT;
RETURN argument;
END
replace e with one of (a,e,i,f,k)
SELECT smart_replace(table.column, 'e', 'aeifk')
replace 3 with one of 0-9
SELECT smart_replace(table.phone, 'e', '0123456789')
I want to create records of tier 2 with using the name of tier 1 records and appending 2 in their name. Like "Tools 2", I want to create records for other records (with tier = 1).
I am using this query in mysql -
insert into dummy_1 (ca2_name, ca2_tier) VALUES (CONCAT(select ca2_name from dummy_1 where ca2_tier=1, " 2"), 2);
But it is throwing error - "CONCAT" is not valid at this position, expecting a complete function. Not sure how to implement this.
When you use a subquery as an expression, it has to be enclosed in parentheses, in addition to the parentheses that are used for wrapping the CONCAT arguments.
insert into dummy_1 (ca2_name, ca2_tier)
VALUES (CONCAT((select ca2_name from dummy_1 where ca2_tier=1), " 2"), 2)
But a better way to write this is to use a SELECT instead of VALUES.
INSERT INTO dummy_1 (ca2_name, ca2_tier)
SELECT CONCAT(ca2_name, ' 2'), 2
FROM dummy_1
WHERE ca2_tier = 1
So I have a task to show all teachers who have their first 3 letters of name and surname the same.
I know I should use substring but I cant figure this out....
select SUBSTRING(name_surname,1,3)
from teacher
where
This is what I did so far
First three letters of any value? SUBSTR(). As you know:
SUBSTR(surname, 1, 3)
Comparing two values of these for a WHERE filter?
WHERE SUBSTR(surname, 1, 3) = SUBSTR(given, 1, 3)
I'm very new to access. I have a data in my column that looks similar to this:
JONES/KEN
SMITH/TAMMY
MILLER FRED
PICARD.JOHN
Am I able to grab the letters before the first non-alphanumeric?
So my result would be:
JONES
SMITH
MILER
PICARD
How about a derived table:
SELECT Left([Surname],InStr([Surname],[NonAlpha])-1) AS LeftName,
MainTable.Surname
FROM MainTable,
(SELECT " " As NonAlpha From Table1
UNION
SELECT "." As NonAlpha From Table1
UNION
SELECT "," As NonAlpha From Table1
UNION
SELECT "/" As NonAlpha From Table1) AS n
WHERE (((MainTable.Surname) Like "*" & [nonalpha] & "*"));
Table1 is a scratch table, it does contain records but the query will only
return the four assigned rows (,./ )
Maintable is the table with a field Surname, which is the field to be split.
Unfortunately, I don't know of a "Word" function that's available in some languages. I would do it with brute force checking using Instr and then Mid to extract the code. The construct would be very convoluted to get every kind of character.
I've used the iif function and nested it - this the basic format here:
iif (instr (fieldname,"{the character}") > 0,
mid(fieldname,1, instr(fieldname,"{the character}")-1,
fieldname{or go further into ifs})
Using your sample data with Client Name as the field and 3 conditions - space, / and period. IT does work, but it's ugly - you will have to scroll pretty far to the right to get everything:
ShortName: IIf(InStr(1,[client_name]," ")>0,
mid(client_name,1,InStr(1,[client_name]," ")-1),
IIf(InStr(1,[client_name],"/")>0,
mid(client_name,1,InStr(1,[client_name],"/")-1),
IIf(InStr(1,[client_name],".")>0,
mid(client_name,1,InStr(1,client_name],".")-1),
Client_Name)))
Put this in a query based on your table.