Display column(D) value if column(C) value ="x" else Null - show all column(A) values - obiee

I have an analysis listing all open jobs(A), job status(B), candidate status(C), candidate name(D).
I want to see all (A) and (B) and IF (C) = 'offer' then show (C) & (D) else NULL for both.
I have done well by finding solutions and learning on my own, but I couldn't find the right way to ask my question without providing a rudimentary example.

Related

Returning the Maximum of Date1 and Date2 in Cognos 10.2

At my company we've recently moved from SSRS to a Cognos-based Reporting System, I don't have much experience with Cognos as a whole and am running into some issues that seem trivially easy to fix but I am struggling so far.
In our DB we segregate two kinds of contact date information [Date Emailed] and [Date Called], I'm attempting to combine both to get a [Date Contacted] field returned.
Is there a way for me in Cognos report builder to find the max of both of these data items?
I would have expected some kind of "c = MAX(a,b)" function like the below to be available but from what I've seen, apparently not.
[Date Contacted] = MAX([Date Emailed], [Date Called])
Also, we have no access to modify SQL or any Cognos related part except the Report Builder which makes this all the more fun.
I feel like the answer will be building a CASE statement to do this, but I'd rather stay away from CASE if I can.
Thanks,
Blu
I wonder if you could use _days_between to determine which is the newer date.
Something like this:
Case
(_days_between (X, Y) > 0 )
then (x)
// or Y; I can't remember whether the value returned is a negative or positive if the first parameter is greater than the second. The expression editor's help will say. Anyway, this is just to point you in a direction rather than me coming down from Mount Sinai.
case
(_days_between (X, Y) > 0 )
then
(x) // or Y;
Else (x or y but it doesn't matter as there's no difference )

Report Builder Expressions

Im new to Report Builder and having issues with some expressions that Im trying to implement in a report. I got the standard ones to work however as soon as I try any distinctions, I get error messages. Over the last couple weeks, Ive tried many combinations, read the expression help, google and looking at other questions at internet sites. To reduce my frustrations, I even would jump to other expressions and walk away hoping I would have different insight coming back.
Its probably something simple or something I dont know about writing expressions.
Im hoping that someone can help with these expressions; they are the versions I get the least errors with(usually just expression expected) and show what Im trying to accomplish.
=IIF((Fields!RECORDFLAG.Value)='D',COUNTDISTINCT(Fields!TICKETNUM.Value),0)
=IIF((Fields!TRANSTYPE.Value)='1' and (Fields!RECORDFLAG.VALUE)='A' or
'B',SUM(Fields!DOLLARS.Value),0)
=IIF((Fields!TRANSTYPE.Value)='1' and
(Fields!RECORDFLAG.VALUE)='P',SUM(Fields!DOLLARS.Value),0)
=Sum([DOLLARS] case when [RECORDFLAG]='P' then -1*[DOLLARS])
Thank You.
=IIF((Fields!RECORDFLAG.Value)=”D”,COUNTDISTINCT(Fields!TICK‌​ETNUM.Value))
The error message gives you the answer here - no false part of the iif() has been specified. Use =IIF((Fields!RECORDFLAG.Value)=”D”,COUNTDISTINCT(Fields!TICK‌​ETNUM.Value), 0)
=IIF((Fields!TRANSTYPE.Value)="1" and (Fields!RECORDFLAG.VALUE)="A" or "B",SUM(Fields!DOLLARS.Value),0)
This is not how an OR works in SSRS. Use:
=IIF((Fields!TRANSTYPE.Value)="1" and (Fields!RECORDFLAG.VALUE="A" or Fields!RECORDFLAG.Value = "B"),SUM(Fields!DOLLARS.Value),0)
The 0s are returned due to your report design. countdistinct() is an aggregate function - it's meant to be used on a set of data. However, your iif() is only testing on a per row basis - you're basically saying "if the current row is thing, count all the distinct values" which doesn't make sense. There are a couple of ways forward:
You can count the number of times a certain value occurs in a given condition using a sum(). This is not the same as the countdistinct(), but if you use =sum(iif(Fields!RECORDFLAG.Value = "D", 1, 0)) then you will get the number of times RECORDFLAG is D in that set. Note: this requires the data to be aggregated (so in SSRS, grouped in a tablix).
You can use custom code to count distinct values in a set. See https://itsalocke.com/aggregate-on-a-lookup-in-ssrs/. You can apply this even if you have only one dataset - just reference the same one twice.
You can change the way your report works. You can group on Fields!RECORDFLAG.Value and filter the group to where Fields!RECORDFLAG.Value = "D". Then in your textbox, use =countdistinct(Fields!TICKETNUM.Value) to get the distinct values for TICKETNUM when RECORDFLAG is D.

How to change operator precedence (first OR, then AND) in Team Foundation Queries?

Background:
Visual Studio 2015 allows to create queries on your work items, bugs etc. stored in the Team foundation server (TFS). There is a query editor where you add conditions like
which will return bugs in the current projects that are not closed and resolved. So far it works fine, the bugs are replicated from an external system (HP ALM) into TFS.
If I now want to restrict bugs being assigned to me only, I can use the "Assigned To" field and add it as contition, but ALM uses a different account which is tracked by the "HP ALM Assigned To" field.
So I want to create a condition like
(Team Project = #Project) AND (State <> Closed) AND (State <> Resolced)
AND (HP ALM Assigned To = "myALMID" OR Assigned To = #Me)
But as you can see the query editor does not allow to enter brackets, and the condition as it is shown above does not do the right thing, because it will evaluate as
(Team Project = #Project) AND (State <> Closed) AND (State <> Resolced)
AND (HP ALM Assigned To = "myALMID")
OR Assigned To = #Me
which appears to be not the same - instead it shows all items assigned to #Me OR all items meeting the condition
(Team Project = #Project) AND (State <> Closed) AND (State <> Resolced)
AND (HP ALM Assigned To = "myALMID")
because the AND operator takes precedence over OR.
Question:
What do I need to change so the query is working as expected?
Update: I tried it with grouping, as suggested by Daniel Mann, but that does also not return the results I want:
I tried to change the OR HP ALM Assigned To = "myALMID" to AND HP ALM Assigned To = "myALMID" but that still does not do it right.
When you select two or more clauses, you can group them together. There should be buttons on the UI and items on the right-click context menu.
Group clauses works on my side. You may check whether the field HP ALM Assigned To has correct value:
Considering both hints from Cece - MSFT and Daniel Mann, I modified the query as follows:
You can see that now there are only 14 items returned, which is correct. The issue seems to be solved, thanks both - I upvoted you because you both contributed to the solution.
Now let me summarize, what I learned from this:
The order in which the conditions appear seem to matter. I moved the group containing HP Assigned to and Assigned to to the top to be able to select only "OR" between them and grouped it together
I had the ALM ID in quotes, which is wrong - so I removed them.
I grouped the state conditions together (but I am not sure if that is required)
What is a pity is that the query editor does not allow "Not In", only "Not In Group", so I had to repeat the "State" lines for each state I wanted to exclude.

VB6, Adding an integer to a control name in a for loop

I am currently trying you learn VB6 and came across this issue.
I wanted to loop through a for loop and adding a number to a control name.
Dim I As Integer
For I = 1 To 5
S = CStr(I)
If TextS.Text = "" Then
LabelS.ForeColor = &HFF&
Else
LabelS.ForeColor = &H80000012
End If
Next I
This S needs to be added to Text and Label so the colour will be changed without needing to use 5 If Else statements
I hope you can help me with this.
From your comment below:
What i mean is this: If Text1.text = "" Then I need this 1 to be replaced with the variable I, so the for loop can loop through my 5 textboxes and the same for my Labels.
You can't do that (look up a variable using an expression to create its name) in VB6. (Edit: While that statement is true, it's not true that you can't look up form controls using a name from an expression. See "alternative" below.)
What you can do is make an array of your textboxes, and then index into that array. The dev env even helps you do that: Open your form in the dev env and click the first textbox. Change its name to the name you want the array to have (perhaps TextBoxes). Then click the next textbox and change its name to the same thing (TextBoxes). The dev env will ask you:
(Don't ask me why I have a VM lying around with VB6 on it...)
Click Yes, and then you can rename your other textboxes TextBoxes to add them to the array. Then do the same for your labels.
Then your code should look like this:
For I = TextBoxes.LBound To TextBoxes.UBound
If TextBoxes(I).Text = "" Then
Labels(I).ForeColor = &HFF&
Else
Labels(I).ForeColor = &H80000012
End If
Next
LBound is the lowest index of the control array, UBound is the highest. (You can't use the standard LBound and Ubound that take the array as an argument, because control arrays aren't quite normal arrays.) Note also that there's no need to put I on the Next line, that hasn't been required since VB4 or VB5. You can, though, if you like being explicit.
Just make sure that you have exactly the same number of TextBoxes as Labels. Alternately, you could create a user control that consisted of a label and a textbox, and then have a control array of your user control.
Alternative: : You can use the Controls array to look up a control using a name resulting from an expression, like this:
For I = 1 To 5
If Me.Controls("Text" & I).Text = "" Then
Me.Controls("Label" & I).ForeColor = &HFF&
Else
Me.Controls("Label" & I).ForeColor = &H80000012
End If
Next
This has the advantage of mapping over to a very similar construct in VB.Net, should you migrate at some point.
Side note:
I am currently trying you learn VB6...
(tl;dr - I'd recommend learning something else instead, VB6 is outdated and the dev env hasn't been supported in years.)
VB6's development environment has been discontinued and unsupported for years (since 2008). The runtime is still (I believe) supported because of the sheer number of apps that use it, although the most recent patch seems to be from 2012. But FWIW, you'd get a better return on your study time learning VB.net or C#.Net (or any of several non-Microsoft languages), rather than VB6...

Crystal Reports - change group header suppress formula programmatically

Using Crystal Reports 10 and vb6/classic (although I expect its the same in any language),
is it possible to change a suppression formula on a Group header section dynamically from code.
I'm basically changing the GroupConditionField on a specific group dynamically according to user input, but on that group header there is a suppression field formula containing a check on a grouped sum.
Sum ({#ColourTotal}, {Table.Field}) =0
If this is true, the group gets suppressed. This obviously comes up with an error complaining it can't find the group when the GroupConditionField is changed through code.
So is there a way to change the suppress formula for a specific group from within code?
I apologize this is C# but I had it handy. I need to so something similar so I have a formula that I set to a value from my program. The report checks this value to decide whether to suppress or not. I suspect you can use the same technique to change the formula, but I'm too lazy to test it my self.
report.DataDefinition.FormulaFields["Florida"].Text = (Convert.ToBoolean(option.EffectiveValue) == true ? "1" : "0");
This code just sets the formula field, "Florida" to either 0 or 1.
I believe I have found a way to do it using the Group Selection Formula under
Report->Selection Formulas-> Group inside the actual report.
Not ideal and will involve some reformatting but should work.

Resources