Visibility of report field dependent on the value of another field - reporting-services

I have two columns one [CUS SKU], the other [UPC].
I have 2 specific id's 1234, 1233 and many others but only care if these two show up.
My problem-
If either of these two show up on both columns I only want to display one column and hide the other.
If another id is displayed in both columns display both.
If another id shows up on either column and neither of the two important ids are shown then display in either of the columns.
also the two important id's will sometimes have 0 or 00 in front, how do i accommodate for that in there as well.
this is what i tried in each column but had no luck, it was displaying the same.
=IIF (Fields!CUS_SKU.Value = ("1234") or Fields!CUS_SKU.Value = ("1233") and Fields!UPC.Value = ("1234") or Fields!UPC.Value = ("1233"), True, False)
and
=IIF (Fields!CUS_SKU.Value <> ("1234") or Fields!CUS_SKU.Value <> ("1233") and Fields!UPC.Value = ("1234") or Fields!UPC.Value = ("1233"), False, true)

When mixing AND and OR in a condition, you need to use parens carefully. Try this:
=IIF ((Fields!CUS_SKU.Value = ("1234") or Fields!CUS_SKU.Value = ("1233")) and (Fields!UPC.Value = ("1234") or Fields!UPC.Value = ("1233")), True, False)

Related

Nested if statement for SSRS with true and false

I am trying to hide a row when the id = 0012. My report has a group and detail level rows in it.
I also have one more filter Expanded, which I use to hide and show the detail level rows.
This is my if statement that works correctly to show and hide the detail level rows.
=IIF(Parameters!Expand.Value = False , True, False)
Now how can I hide the id = 0012 row from showing up regardless of what value I pass onto my if statement. I do not want to show the 0012 id at all in the report.
I tried this
=IIF(Parameters!Expand.Value = False or (Fields!ID.Value) = 0012, True, False)
but this only works or one of the values for my Expanded filter, when I chose false, I am able to collapse the detail row and see it again.

How can I use Logical Operator between 2 Select Statements?

I have few tables which are joined by some conditions.
What I am trying to achieve is Combine 2 SELECT statements in such way where
If there is data in Condition 1 display them OR go to Condition 2 and display data
Condition 1 - I am getting record from table say for exampleA, B, C and D based on some conditions
Condition 2 - I am getting record from table say for example A, B, C and E based on some conditions
What is am trying to achieve is
Display record if it exists in Condition 1
OR
Display record if it exits in Condition 2
Condition 1/ Query 1 - Display data
async getData() {
try {
const data = await this._conn.query(`
select first_name.value_name,quiz_table.answer, windows,player,first_name.value_id,country_place,current_name, pet_name, marker, relations
from schema_name.plugin,schema_name.quiz_table,schema_name.first_name, schema_name.value_version, schema_name.relationss
where plugin.answer= quiz_table.answer
and quiz_table.windows=first_name.value_id
and marker is not null
and schema_name.value_version.value_id= schema_name.first_name.value_id
and schema_name.value_version.caste= schema_name.first_name.caste
and schema_name.value_version.value_name= schema_name.first_name.value_name
and schema_name.value_version.version_number= schema_name.first_name.version_number
and schema_name.relationss.value_id= schema_name.first_name.value_id
and schema_name.relationss.caste= schema_name.first_name.caste
and schema_name.relationss.value_name= schema_name.first_name.value_name
and schema_name.relationss.version_number= schema_name.first_name.version_number
and schema_name.quiz_table.windows= schema_name.first_name.value_id
and in_process='N'
}
OR
Condition 2/ Query 2 - Display data
select schema_name.relationss."relations", schema_name.quiz_table."answer", schema_name.quiz_table."windows", schema_name.quiz_table."in_process", schema_name.quiz_table."object_name", schema_name.quiz_table."processed_date", schema_name.quiz_table."player", schema_name.quiz_table."country_place", schema_name.tools."mesh_scope_note", schema_name.plugin."current_name", schema_name.plugin."pet_name"
from schema_name.quiz_table, schema_name.tools, schema_name.plugin, schema_name.relationss, schema_name.value_version
where (in_process = 'N'
and schema_name.quiz_table."windows" = schema_name.tools."value_id"
and schema_name.quiz_table."player" = schema_name.tools."language"
and schema_name.quiz_table."answer" = schema_name.plugin."answer"
and schema_name.relationss."language" = schema_name.quiz_table."player"
and schema_name.relationss."language" = schema_name.tools."language"
and schema_name.relationss."caste" = schema_name.tools."caste"
and schema_name.relationss."value_name" = schema_name.tools."value_name"
and schema_name.relationss."version_number" = schema_name.tools."version_number"
and schema_name.relationss."value_id" = schema_name.tools."value_id"
and schema_name.value_version."value_id" = schema_name.tools."value_id"
and schema_name.value_version."version_number" = schema_name.tools."version_number"
and schema_name.value_version."caste" = schema_name.tools."caste"
)
NOTE - 1-> I cannot use function or procedure here.
2-> Both the `Conditions` contains `different data`
The problem is, how will the computer choose which option to go to? A computer does not choose, it can't. You have to provide some metric for which to choose. The boolean operator || (or) is for checking if either is true (declarative-sorta), not for imperative. You can 'ask' "is a or b true?" but you can't tell a computer, "do this or that" without any weight to either one which would explain to the computer which to pick and when.
What would be possible is asking,
"If there is data in Condition 1 display them; if not, go to Condition 2 and display data".
If that suits your needs, this is how it could be coded (this is just the framework).
if (data1 != null) {
show data1
}
else {
show data2
}
Or your data could be non-null, but have no contents, in which you could try to get some data from it (say, getChildren() (totally random, I'm just making that up):
if (data1.getChildren() != null) {
show data1
}
else {
show data2
}
I hope you know that this is just pseudocode for the theory of it. show_ is not actual code, it's just the placeholder for whatever you would write. Would this work - checking if it is null and/or checking if its contents are null (i.e., it's empty/without data) and if so then going to the next dataset?
I don't know sql, but I thought that idea of check-null/check-contents-null might help.

SSRS Row Visibility

I am using the Switch function in Reporting Services to determine the visibility of a row. It happens that I am using more that one column or field to test my expression like so:
=Switch(Parameters!View.Value = "Green" AND Fields!Tax.Value = "N",TRUE,Parameters!View.Value = "Current" AND Fields!PastVal.Value = 0 AND Fields!DatePay.Value = 0 AND Fields!Comment.Value = 0,True)
With the expression above, I want that if the first part is true, the row should be hidden likewise for the second part of the expression, I want to hid a row when all the conditions are met. But this not yielding the desired result.
I equally tried with another expression like so:
=IIF(Parameters!View.Value = "Green" AND Fields!Tax.Value = N",False, IIF(Parameters!View.Value = "Current" AND Fields!PastVal.Value = 0 AND Fields!DatePay.Value = 0 AND Fields!Comment.Value = 0,True,False))
That still did not work.
I anticipate your help. Thank you
If I follow you correctly, I think putting both conditions in an IIF and separating them with an "OR" will work:
=IIF( (Parameters!View.Value = "Green" AND Fields!Tax.Value = "N") OR (Parameters!View.Value = "Current" AND Fields!PastVal.Value = 0 AND Fields!DatePay.Value = 0 AND Fields!Comment.Value = 0) ),True,False)

Creating a value in a control on a form

I need to create a value in a text box control upon triggering a certain event to allow me to then relink my forms to a different master/child link scheme. This value is to be used subsequently to create an if statement. For some strange reason, the value is generated and formatted correctly but regardless of what is in the text box, the If statement does not recognise this value and knows it only as blank. I tried numbers, letters but everything is the same.
In my example below, after updating the control (text box) 'txtDeviation' to the value of '1', for some strange reason is not recognised in as the value 1.
Private Sub cmdSkillsTracking_Click()
Form_frmValueChain01!frmValueChain02.SetFocus
Form_frmValueChain01.Pagina370.Visible = False
Form_frmValueChain01.Pagina371.Visible = True
If txtDeviation01 < 1 Then
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01e"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain17.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain17.LinkChildFields = "IDskillsmatrix"
Form_frmValueChain01.Form.frmValueChain16.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain16.LinkChildFields = "ID"
Else
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain14.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain14.LinkChildFields = "subprocessID"
Form_frmValueChain01.Form.frmValueChain10c.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain10c.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain101.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain101.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01e"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain17.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain17.LinkChildFields = "IDskillsmatrix"
Form_frmValueChain01.Form.frmValueChain16.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain16.LinkChildFields = "ID"
End If
Two things I see here;
Since you are using a less than operator, you seem to want to treat
this text box value as numeric. If so, you will need to convert the
text value of the text box to numeric.
Next,you need to prefix the reference to the text box with "me."
Your IF statement should look like this;
If val(me.txtDeviation01) < 1 Then
...

Correlate 2 columns in SQL

SELECT ica.CORP_ID, ica.CORP_IDB, ica.ITEM_ID, ica.ITEM_IDB,
ica.EXP_ACCT_NO, ica.SUB_ACCT_NO, ica.PAT_CHRG_NO, ica.PAT_CHRG_PRICE,
ica.TAX_JUR_ID, ica.TAX_JUR_IDB, ITEM_PROFILE.COMDTY_NAME
FROM ITEM_CORP_ACCT ica
,ITEM_PROFILE
WHERE (ica.CORP_ID = 1000)
AND (ica.CORP_IDB = 4051)
AND (ica.ITEM_ID = 1000)
AND (ica.ITEM_IDB = 4051)
AND ica.EXP_ACCT_NO = ITEM_PROFILE.EXP_ACCT_NO
I'm trying basically say since the exp account code is '801500' then the Name should return "Miscellaneous Medic...".
It seems as if what you are showing is not possible. Have you edited the data in the editor??? You are joining using ica.EXP_ACCT_NO = ITEM_PROFILE.EXP_ACCT_NO . Therefore, every entry with EXP_ACCT_NO = 801500, should also have the same COMDTY_NAME.
However, it could be the case that your IDs are not actually numbers and that they are strings with whitespace (801500__ vs 801500 ). But since you are not performing a left-outer join, it would also mean you have an entry in ITEM_PROFILE with the same whitespace.
You also need to properly normalize your table data (unless this is a view) but it still means you have erroneous data.
Try to perform the same query, but using the TRIM function to remove whitespace: https://stackoverflow.com/a/6858168/1688441 .
Example:
SELECT ica.CORP_ID, ica.CORP_IDB, ica.ITEM_ID, ica.ITEM_IDB,
ica.EXP_ACCT_NO, ica.SUB_ACCT_NO, ica.PAT_CHRG_NO, ica.PAT_CHRG_PRICE,
ica.TAX_JUR_ID, ica.TAX_JUR_IDB, ITEM_PROFILE.COMDTY_NAME
FROM ITEM_CORP_ACCT ica
,ITEM_PROFILE
WHERE (ica.CORP_ID = 1000)
AND (ica.CORP_IDB = 4051)
AND (ica.ITEM_ID = 1000)
AND (ica.ITEM_IDB = 4051)
AND trim(ica.EXP_ACCT_NO) = trim(ITEM_PROFILE.EXP_ACCT_NO);