SSRS Report Parameter causing problems - dax

I am facing a weird problem with SSRS Report Parameters. Currently working on SSRS 2016 version. We Connect to SSAS Models and create Data_sets using DAX Queries in the Report.
Here is the sample DAX Query used in my report Dataset,
evaluate
summarize(
calculatetable(
('Field Measures',
PATHCONTAINS(substitute(
substitute(
substitute(
#Parameter_District
, "{ ", "")
, " }", "")
, ",", "|") , 'Field Location'[District]),
PATHCONTAINS(substitute(
substitute(
substitute(
#Parameter_City
, "{ ", "")
, " }", "")
, ",", "|") , 'Field Location'[City])
)
'Field Fact'[Field Interview Number],
'Occurred Date'[Date],
'Occurred Date'[Year]
))
I have two parameters (District and City) defined in this query and both the fields are coming from the same table 'Filed Location'.
The problem I am facing is that, this query works well if I remove the 2nd Parameter "CITY". But it fails when I include this in the query. for simplicity I have mentioned only 2 parameters here, but I have around 5 parameters coming from the same table which were working fine.
I am banging my head why this happens only when I include [CITY] Object in the parameter list and why it works good when I remove this. Literally I am out of my mind :(
Please suggest me some way to debug this issue.
Thanks a bunch.
Balaji

I got the solution for my issue, but I don't have a logical reason why it works.
Let me re-post the DAX Query that I was using in my report,
evaluate
summarize(
calculatetable(
('Field Measures',
PATHCONTAINS(substitute(
substitute(
substitute(
#Parameter_District
, "{ ", "")
, " }", "")
, ",", "|") , 'Field Location'[District]),
PATHCONTAINS(substitute(
substitute(
substitute(
#Parameter_City
, "{ ", "")
, " }", "")
, ",", "|") , 'Field Location'[City])
)
'Field Fact'[Field Interview Number],
'Occurred Date'[Date],
'Occurred Date'[Year],
"Field Count",[FieldInterview - Count]
))
If we observe the original code I post earlier and the one I posted now, there is one line difference between them. i.e. The Measure Value (Field Count). while formatting my question I removed this last line of code (by mistake).But then when I revisited my own question for any probable answers, I noticed this difference and I just tried to use the query by removing the above mentioned Measure value and it just worked like magic!!
So, I really did not understand how Measures, Joins and Parameters work internally. I am still open for any kind of discussion/inputs from experts here.
Thank you.
Balaji

Simple way , Instead of creating parameter using DAX , go for Filter
Create Main dataset1 (all requried fields including city column)
Create Dataset2 for parameter for example (get only city column in this dataset)
Create parameter using the Dataset2
then go to main dataset1 - properties - filter. - add column and parameter in the expression.
this will work

Related

DAX - CONCATENATEX TO FILTER AN UNRELATED TABLE

I have an unrelated table ('Selected Values Slicer') that is then used as a slicer to select values. I need to use these selected values to filter another table ('Results Table').
Doesn't seem to be working as I'd expect it to. The output shows a 0 when more then 1 item is selected but works ok when 1 value is selected
VAR __SelectedValues =
CONCATENATEX(
ALLSELECTED('Selected Values Slicer'[Description]),
'Selected Values Slicer'[Description],
",")
RETURN
CALCULATE(
[TotalCount],
'Results Table'[Description] IN {__SelectedValues}
)
__SelectedValues RETURNS "Selected Value 1,Selected Value 2"
What I'm expecting is __SelectedValues to RETURN "Selected Value 1","Selected Value 2"
The following syntax will return "Selected Value 1","Selected Value 2" as you asks
CONCATENATEX(
ALLSELECTED('Selected Values Slicer'[Description])
,"""" & 'Selected Values Slicer'[Description] & """"
,","
)
Regarding filtering. I was trying to use the string as filter, but I didn't manage it the way you want. I can't say what is the reason for DAX not to do that, but asked Marco Russo about the case. So, I'll add the answer since a get it (upd. the answer added to the end of the answer).
To filter the table with a string of CONCATENAX() you can try the following sytax ( I checked it with a dummy data):
VAR __SelectedValues =
CONCATENATEX(
ALLSELECTED('Selected Values Slicer'[Description])
,'Selected Values Slicer'[Description]
,","
)
RETURN
CALCULATE(
[TotalCount]
,FILTER(
'Results Table'
,CONTAINSSTRING(
__SelectedValues
,'Results Table'[Description]
)
)
)
Regarding result you want to achieve. A below code, I believe, is enough. You have a slicer and you want to apply its values to the result. I have a feeling, you don't need to change a contex to the slicer and no context can influence it. If it's not like that, then the code should be altered, but the idea remains the same - get a column with a unique values and use it as a filter. I checked the syntax and it was functioning.
CALCULATE(
[TotalCount]
,'Results Table'[Description] IN VALUES('Selected Values Slicer'[Description])
)
P.S.
My first answer was not ok. I messed some info and gave an incorrect input. I'm sorry for that.
P.S.S. The answer from Marco Russo:
"IN looks for an exact match in a table (IN VALUE is a better choice for your need, and a better one is:
TREATAS ( VALUES ( slicer[column1] ), table[color] )
The result of CONCATENATEX is a string, so you should use CONTAINSSTRING - DAX Guide to do the search, but it would be slower and potentially inaccurate."
This is the answer from his colleague

Data still appearing in Oracle BI report when I dont give any input in the parameter

I have made a BI report using Oracle SQL. When I give an input to the parameter field, I get data. But, when I leave the parameter field as empty without giving any input, still the data appears instead of disappearing. What changes should I do in the SQL or OTBI dashboard to clear this problem?
**SELECT
AIA.INVOICE_NUM
, AHA.RELEASE_REASON
, DECODE (AHA.HELD_BY,'5', (SELECT ALC.DISPLAYED_FIELD
FROM AP_LOOKUP_CODES ALC
WHERE ALC.LOOKUP_TYPE(+) = 'NLS TRANSLATION'
AND ALC.LOOKUP_CODE(+) = 'SYSTEM'),
AHA.HELD_BY) "HELD BY"
, DECODE (AHA.LAST_UPDATED_BY,'5', (SELECT ALC.DISPLAYED_FIELD
FROM AP_LOOKUP_CODES ALC
WHERE ALC.LOOKUP_TYPE(+) = 'NLS TRANSLATION'
AND ALC.LOOKUP_CODE(+) = 'SYSTEM'),
AHA.LAST_UPDATED_BY) "RELEASE_BY_USER_NAME"
FROM
AP_HOLDS_ALL AHA
, AP_INVOICES_ALL AIA
WHERE 1=1
AND AHA.INVOICE_ID (+) = AIA.INVOICE_ID
AND (AIA.INVOICE_NUM IN (:INVOICE_NUM) OR COALESCE(NULL,:INVOICE_NUM) IS NULL)**

Splitting down a data frame column from ib_insync

I am reasonably new to python and am struggling to breakdown the below.
Stock(conId=3691937, symbol='AMZN', exchange='SMART', primaryExchange='NASDAQ', currency='USD', localSymbol='AMZN', tradingClass='NMS')
This is a row in a dataframe with the column header order_contract
how do i break this down into seperate columns with headers conId , symbol , exchange , primaryExchange , currency , localSymbol , tradingClass
and the rows 3691937 , AMZN , SMART , NASDAQ , USD , AMZN , NMS
Sorry this isnt a well formatted question i am new to stackoverflow. Thanks in advance
Assuming ib_insync contract object is what you showed, this should suffice:
df = pd.DataFrame([x.__dict__ for x in df.order_contract])

How to display drop down options alphabetically without worrying about case sensitive in classic asp?

I have a drop down box in my classic ASP page and using MS SQL for database. The drop down list includes the brand names starting with lower case, upper case and starting brand name with numbers.
For instance, itcosmetics, Colorpop Cosmetics and 5 Hour energy respectively. Currently, this dropdown is showing/displaying brands alphabetically but by case i.e. lower case, number, upper case.
In other words, it is displaying all lower case brand name alphabetically first then the brand with numbers alphabetically and finally brand names starting with uppercase alphabetically.
However, what I am trying is : I want to display my options according to the alphabetical orders without worrying about the case of the brand name.
for example: if the brand names are 1 apple, applea, Appleb, 3 fans, balla, Ballb, cat, Doll.
Currently, its displaying drop down option as following:
applea
balla
cat
1 apple
3 fans
Appleb
Ballb
Doll
But I want something like following:
1 apple
3 fans
applea
Appleb
balla
Ballb
cat
Doll
How can I do that?
My code :
<select>
<OPTION value=0>-- SELECT --</OPTION>
<%
DIM RS, varQueryBrand, varBrand
IF Request.QueryString("brandID") <> "" THEN
varQueryBrand = Request.QueryString("brandID")
ELSE
varQueryBrand = "SELECT"
End IF
SQL = "SELECT DISTINCT(brand) as brand FROM tblproduct"
SET RS=objConn.Execute(SQL)
IF NOT (RS.BOF and RS.EOF) THEN
WHILE NOT RS.EOF
varBrand = RS("brand")
IF LCase(varQueryBrand) = LCase(varBrand) THEN
Response.Write "<option selected value=""" & replace(RS("brand")," & ","#") & """>" & RS("brand") & "</option>"
ELSE
Response.Write "<option value=""" & replace(RS("brand")," & ","#") & """>" & RS("brand") & "</option>"
End IF
RS.MoveNext
WEND
END IF
RS.close
SET RS = nothing
%>
</select>
I tried writing ORDER BY brand at the end of SQL statement, but there was no chage in the output. So can you please help me?
You are likely using a Collation with the CS designation in it like Latin1_General_CS_AS for example.
To avoid the Unicode Sorting, switch to a Binary Collation to get the expected sort order.
SELECT DISTINCT brand
FROM tblproduct
ORDER BY brand COLLATE Latin1_General_bin
A slightly messier approach is to use a sub query to wrap a lowercase version of the Brand column and use that for sorting.
SELECT x.brand
FROM (
SELECT DISTINCT brand, LOWER(brand) [brand_lower]
FROM tblproduct
) x
ORDER BY x.brand_lower
As #Martha point's out don't forget to specify an ORDER BY in your SQL string in Classic ASP.
Useful Links
ORDER BY … COLLATE in SQL Server
From what it looks like, you aren't currently sorting your results at all, so you're getting whatever default order SQL Server cares to come up with.
Most databases are automatically set to case-insensitive sorting, so unless your database is set up strangely, the following should work:
SQL = "SELECT DISTINCT brand FROM tblproduct ORDER BY brand"
If that doesn't work and you don't feel like messing around with the COLLATION settings, you can sort by an all-lowercase (or all-uppercase) version of the field:
SQL = "SELECT DISTINCT brand FROM tblproduct ORDER BY LOWER(brand)"

How to get sets of Records in VB6?

Hey guys, just want to ask you a simple question that I know you're familiar with... I am using VB6, I just want to get sets of records from my database. What I mean is that I have UserID and with a part of code provided below, it only gets a single set of record. Like for instance, the value of UserID is A12, and so, all sets of records with the UserID of A12 must display in Textboxes respectively with the aid of datPayroll.Recordset.MoveNext.
With datPayroll
.RecordSource = "select * from tblpayroll where empid like '" & UserID & "'"
.Refresh
Me.txtRegularHours.Text = .Recordset.Fields!reghours
End With
-datPayroll : DataControl
-txtRegularHours : Textbox
-UserID : Variable
You probably want to look at MoveFirst, MoveNext, etc. and also EOF
Here is a link or two to get you started:
EOF, BOF
MoveFirst, MoveNext
You need to check that you have some data in your Recordset using EOF, then MoveFirst to move to the first record, and loop through using MoveNext.

Resources