I have the following set analysis with one condition.
=sum({1} bank_shr_bal)/1000000
I need to create a second condition that filters the months the data collects from. The date column needs to be greater than a variable created called "minusYear" and the dimension I'm comparing it to is called MonthEnd. I'm really not sure how to do a greater than with Qlikview set analysis.
Thank you in advance for the help.
You can use the <> set modifier syntax with your MonthEnd field. It would look like this:
=sum({1<MonthEnd=">$(minusYear)">}bank_shr_bal)/1000000
The set you are are looking at is the entire universe because you used the 1 as your set identifier. Then the modifier <MonthEnd=">$(minusYear)"> restricts the the set to only those values meeting the condition defined for MonthEnd. The " is used for expressions in QV so we can write the expression > $(minusYear) between the quotes and the expression will get resolved.
Related
Not sure why this isn't working.
When I run the query without HAVING segment ilike 'Enterprise' I get results (see screenshot) but when I add it back in the query returns nothing despite clearly containing instances where segment = 'Enterprise'. I can't find any instances online where having is used to filter for strings so I'm thinking this just isn't possible. Could someone confirm if this is the case and if there is an alternative method if so? Thanks.
You can't use HAVING to filter for strings, you can only use it to filter for numeric values. To filter for strings, you'll need to use the WHERE clause.
I have two EXCEL datasources. 175,000 rows. I'm trying to set up a join (Add New Join Clause) using the INNER option between the two datasources. The left datasource includes certain member id #s. Unfortunately, the right datasource's member id #s are within a large field called member Desc. Something like below,
Datasource Left
Member ID #
ALL89098
Datasource Right
Member Desc
YTRNNN TO=ALL89098_KIA TO BE OR NOT OR
POALL89098 JOE
So, I need to deal with two scenarios as you notice from above. The member id is within the Member Desc after a TO= and it could be anywhere like scenario 2 POALL89098
If I can't get this done in Tableau to establish the Join between these two columns from different datasources, since I have both of these datasources loaded into SQL Server DB, I can run SQL statements in SQL since they are in two different Tables within SQL Server DB as well.
I'm trying the use of CONTAINS clause in Tableau such as below but it is running very very slow. it is only Tableau Desktop with 16 GB Ram.
if contains([Member Desc],([Member id #])then
[Member id #]
ELSE
"NOT FOUND"
END
Thanks so much for your time.
SO, IS THERE A WAY TO HAVE THE REGEXP WITHIN IF AND ELSE OR CASE STATEMENTS?
You can create a join calculation. The highlighted dropdown shows where this can be found:
As long as the format of the Member ID in [Member Desc] has some pattern, it can be extracted with Regex. As you mention in your question, one way the ID may present itself is after a "TO=" and it looks like it ends before a "_". The following regex calculated field will pull the string between the two:
REGEXP_EXTRACT([Member Desc],"([^TO=]*)(?=_)")
The result should properly join the two datasources:
The above is an outline which I hope sets you on the right path. I realize that there may be a few different methods in which the [Member ID] presents itself so I wont be able to nail down the exact Regex, but if there is any pattern at all then the format above should work. (ie: even if the only pattern is that [Member ID] is three letters followed by four numbers - or it always starts with an A and ends with something else - etc.)
Regex should also perform better than a contains() function, but do be aware that the function does need to search through every string in every row to make the join.
Edit in response to comment:
To add multiple conditions, try the following method:
IF LEN(REGEXP_EXTRACT([Member Desc],"([^FROM=]*)(?=,)")) > 0
THEN REGEXP_EXTRACT([Member Desc],"([^FROM=]*)(?=,)")
ELSEIF LEN(REGEXP_EXTRACT([Member Desc],"([^TO=]*)(?=,)")) > 0
THEN REGEXP_EXTRACT([Member Desc],"([^TO=]*)(?=,)")
ELSEIF [...Put as many of these as might match your pattern]
THEN [...Put as many of these as might match your pattern]
END
Essentially the calculation is going down the list and trying each possibility. I changed yours a little to look at the length (LEN()) of the returned value which should compare fairly quickly, as it is an integer. As this calculation iterates through each ELSEIF and finds a match, it will stop iterating through the list -- so its important to put the most likely match at the top. The result of the calculated field should be a member ID. If there is no match, there really isn't a need for an ELSE statement because the Inner Join will exclude it automatically.
Edit in response to comment:
Thank you. I see your recommendations.
I think you are going to have to find a way to strip out the member ID from the member desc in SQL. There should be some pattern to Member ID.
For instance is it always 3 letters followed by 5 numbers or something similar.
If you can come up with a pattern, then you can use SQL and some combination of Substring, Charindex, and/or Like %Text% or a regex
pattern to strip out the actual member ID in the SQL Server table as its own field before bringing it into Tableau.
I'm trying to add in a wild card selection to my one of my dropdowns within a SSRS report that passes in a "%" to the query it is linked to but has a label of "All Vendors" to the end user.
Highlighted is where I would like to see "All Vendors"
I attempted to use the available values option as opposed to the get values from a query option with the idea that I could specify an expression that returns the same values as the query and then specify a single value as described above. But when I tried to do this I received an error like:
"A value expression used for the report parameter "VND" refers to a field. Fields cannot be used in report expressions."
The expression I used was:
=Multilookup(Split(Fields!ve_name.Value, ",")
Available Values Window
Could someone tell me if theres an easier way to accomplish this or if my syntax is just bad and that this is the best way to do this?
As alejandro zuleta, mentions in a comment,
Why don't you just use a multiple valued parameter? Multiple valued parameter include a Select All option. Check this
Using a multiple valued parameter helped.
Though this question has been asked, the scenario for all such questions were totally different and didn't answer my question hence asking a new question.
I have hard coded a SQL code in SSRS query field. One of the column is from a
CASE STATEMENT
CASE WHEN (Amt_Requested > 0)
THEN Amt_Requested ELSE Amt_Committed END AS Final_Amount
I want to add a filter for this column where I want records BETWEEN 25000 to 50000
I tried to create an expression on the Design page of SSRS
=iif(Fields!Final_Amount.Value >=25000 AND Fields!Final_Amount.Value <= 50000,Fields!Final_Amount.Value,0)
This satisfies the condition but doesn't filter the data.
I also tried adding a FilterExpression from tablix properties, but it gives an error stating
'Please check the data type returned by the FilterExpression
PL note: The CASE STATEMENT is in SELECT STATEMENT
In the Tablix Filters definition, I would change the data type to Boolean, leave the Operator as =, and set the Value to True.
Then I would set the Expression to return a True/False result as you intially described.
This design is much more flexible as you can easily combine multiple fields, parameters etc in the one Expression. It also avoids the fragility and obscurity of datatype conversions in SSRS.
Could any one please help to fix this expression.
Under the Filter tab i am trying to do values selection from multi-value parameter.
where i have to add value 'C160' if left of column value is 'C15' and in the same manner,
i have to ignore value 'C160' if the column value is 'C16'.
--
My expression is, IIF(COND,TRUE,FALSE)
=IIF(Parameters!Site.Value="C15",Parameters!Site.Value AND "C160",(IIF(Parameters!Site.Value="C16",Parameters!Site.Value AND NOT "C160",Parameters!Site.Value)))
Error: Failed to evaluate the FilterValues.
Thanks
If I understand your requirements correctly, this should do the trick. You can set the filter expression to an expression - it doesn't just have to be a column value.
EXPRESSION (Text)
=Left(Fields!Column.Value,3)
OPERATOR
[=]
VALUE
=Parameters!Site.Value
EDIT
You could add a calculated field to the dataset like so:
Field Name Field Source
========== ============
Site2 =IIF(Fields!Site.Value="C160","C15",LEFT(Fields!Site.Value,3))
And Have your Site parameter have the following Available Values:
Label Value
===== =====
C15 C15
C16 C16
Your filter would then look like this:
EXPRESSION (Text)
=Fields!Site2.Value
OPERATOR
[=]
VALUE
=Parameters!Site.Value
HOWEVER
my two pence worth
It seems like business rules are driving this requirement. I would strongly recommend AGAINST calculating business rules in report expressions. Business rules change over time and it can be cumbersome to change rdl files. Better to have one central location where rules like this are stored. Lookup tables or UDFs are ideal, or at worst a stored procedure or embedded query will do.
It is much better to put this in the dataset if you have the ability to change it. You then have the ability to annotate the code which creates this grouping to include a reason WHY C160 is thought to be the same as C15.