Prompt Page Static Choices - cognos

I am trying to create a prompt on my prompt page to let the user select a specific quarter. for example, the user would select "2018 Q1" from a prompt and the report would know that the dates for "2018 Q1" are between 7/1/2018 and 9/30/2018. Is this possible to do? I have been messing with the static choices, but I am not getting very far.
My Cognos knowledge would be classified as general.

There are a couple ways to do that. You didn't indicate whether you want the choices offered the user in the prompt to be dynamic. Dynamic prompts usually provide a better customer experience and require less maintenance. I'll explain how to do dynamic and if you want static, simply hand enter the values into the prompt rather than source them from a query. The rest of the instructions apply.
Dynamic (preferred)
Create a new query
Name the query something that indicates its function, e.g. 'Quarter Prompt'
Within the query create a new data item to contain what you want the prompt to display to the user.
For example, if you wanted the prompt to show "2018 Q1" you might create this string from a Date table like so:
[Year] + ' Q' + [Quarter]
If you generate the tabular data for this query you will get a list of all year/quarter combinations in your date table:
2018 Q1
2018 Q2
2018 Q3
2018 Q4
2017 Q1
...
Constrain the list to only the range of quarters you want to prompt for.
For instance, if you wanted to only show quarters in the current year you'd add this filter:
[Year] = year(current_date)
After adding this filter you will only see the first four rows of the above output returned. Your users will be given four choices to choose from.
Set the value prompt's Query property to the new query and set both the Use Value and Display Value properties to the data item you defined in the prompt query
To apply the prompt choice to your report, you simply add a filter to the relevant report query that takes the input from the user and compares it against the data:
[Year] + ' Q' + [Quarter] = ?quarterPrompt?
Now, this way of doing it has some potential performance inefficiencies. In order to apply the filter each row will have to be examined, converted into the string format and compared. If you need better performance a better way to do the filter is as follows:
[Year] = substring(?quarterPrompt?,1,4) AND [Quarter] = substring(?quarterPrompt?,7,1)
Since we are only transforming the prompt, which contains only one value and not many, the performance is optimized.
Addendum
My intuition was telling me that there might be an even better way. After poking around, I realized that there's an even more efficient way to handle this by eliminating all string parsing. Here's the parts of the procedure to be amended:
You need to add a new data item as the Use Value passed into the report query.
Create a second data item in the prompt query with the following expression:
[Year] * 100 + [Quarter]
For every year and quarter combination you will now have a number that encodes the combination. For instance, for year 2018 and quarter 2 the new data item will return 201802.
Change the prompt properties. Point the Use Value to the newly created data item.
Change the filter in the report query to use the new numerical value
This would look something like the following:
floor(?quarterPrompt?/100) = [Year]
AND mod(?quarterPrompt?,100) = [Quarter]
This numerical-only operation has the potential to have better performance than the substring-based parsing in the original answer, yet has the same effect.

Related

NetSuite Saved Search formula to get a field's value as of a given date

I am required to use a saved search to answer the question: how many cancelled Sales Orders did we have on a specified date? I must use a saved search because ultimately it will be something viewed on a dashboard (and this is what the end users are used to). I know that I can and how to complete via SuiteScript; this is explicitly a question related to Saved Searches and/or SuiteAnalytics. The status of our sales orders fluctuates more than a “normal company”, i.e. 1 SO might change status 3 or 4 times before being “done”. My initial thought was to create a saved search and add “System Notes fields…” as results. So I’d have something like the following:
For the given date 7/19/20 the status was “Canceled” since 7/19/20 is greater than 6/12/20 and less than 7/22/20. I would like to get this field’s value on 7/19/20 programmatically and display it as a Saved Search results column but I don’t know how. I think I’m stuck because I don’t know how to tell NetSuite in a saved search to look at the date in the row above or below. Said differently I don’t know how to compare the given date to all the system note dates to find the system note date that is right before (use the old value) or after (use the new value) the given date. In excel I would do the following, how do i do this in a NetSuite Saved Search?
To apply a dynamic date filter:
In the Criteria tab, add a date filter:
Filter = System Notes : Date is on today
In the Available Filters tab, add the same date filter:
Filter = System Notes : Date,
Show in Filter Region = Yes

Spotfire: How to use trellis to show 4 elements: 3 years + set of records older than 3 years?

Lets say I have the data about some kind of requests.
I have column determining request's creation date.
I wish to show the requestes Trellis'ed by this date but not the standard way.
I wish all the requests with creation date older than 2013-01-01 to be grouppped in one trellis graph.
I also would like to retain the possibility to have information on both year and quarter level as it is available for typical date column.
The image below show sth similar to what I need but the Empty section comes as the last one and I need it with different label and on the left hand side rather than as it is now on the right hand side.
Any ideas ?
my suggestion is to make two visualizations. you can duplicate the one you've already created and then limit its data by editing the properties for that vis, viewing the Data page, and using the Limit data using expression field, giving an expression like [Date Column] < "2013-01-01". you'd do the same on the second vis except use an expression like [Date Column] >= "2013-01-01".
the easiest way to change (Empty) to "something" is to not leave it empty :) you can create a calculated column with the expression If([Column] is null, "Custom Empty", [Column]) and then use that on the horizontal axis. alternatively you can hide (Empty) values from a visualization by limiting the visualization by an expression like [Column] is not null.
you can adjust the order which values are shown by going to the Edit menu and choosing Column Properties. choose the column, click the Sort Order tab, select Custom Sort Order, and click Configure.

Need to display the columns based on input values in cognos report

I have requirement. I need to create a text box prompt in the prompt page. In that prompt user may enter branch number or warehouse number. based on these input value i need to display the branch number and warehouse number in the list report.
Ex: if user enter branch number i need to display only branch number in the list. If user enter warehouse number i need to display warehouse number in the list.
Two optional prompts, each tied to respective data item in query
Macro prompt in each data item of query, putting a dummy value in if the respective parameter is empty
Create list in report with both columns and measure
Two variables, one for each parameter, each tied to conditional rendering on the list column
I wrote up a similar technique on my blog. This would automatically sum the report based on whatever data item had values entered on its prompt. It uses all built-in Cognos functionality. You would need to adapt slightly to ensure the user entered at least one value - could quickly hack with JS.
If the branch numbers and warehouse numbers don't overlap then you can do the following:
Add both the branch number and warehouse number columns to your query
Create a new data item and put the following as the expression:
CASE
WHEN ?whse_branch_no? BETWEEN 0 AND 10 THEN [Branch Number]
ELSE [Warehouse Number]
END
Add the new data item to your report
If you are filtering on the input as well you could use similar logic:
IF (?whse_branch_no? BETWEEN 0 AND 10)
THEN ([Branch Number] = ?whse_branch_no?)
ELSE ([Warehouse Number] = ?whse_branch_no?)
Obviously, you'd use your own parameter, data item names, and numerical range but the concept is the same.
If the numbers do overlap then it's more difficult.
You could add a two-option radio button that allows the user to select the context for the text box input, with Branch Number and Warehouse Number as choices. Then you just adapt the logic presented above to use the value passed in by the radio button to choose the data item you want.

Duplicate Based on Multi-Coulmn - Only Keep the Earliest and Latest Value

Below is an example of an Excel sheet I'm working with:
Basically, I'm trying to delete the duplicate rows by matching ID, Date and Type. If ID, Date and Type are the same, then, I want to only keep the record with the earliest Time in case of Type = In and the latest Time in case of Type = Out.
So, for example, in the case of ID = 1, there are 3 records for In, I only want to keep the one where Time is: 8:01 as this is the earliest. The other 2 records should be deleted.
Similarly, in the case of ID 3, I want to keep the record where Time = 18:05 as this is the later time out of the 2.
Can this be achieved by Conditional Formatting or is it more complex than that?
Many thanks for your help in advance.
Conditional Formatting does not to me look the best approach. Depending upon how often required (frequently, and VBA may be better) I suggest:
Add a sequential index (so can be sorted back to original order, if required).
Sort on Time (Smallest to Largest) within Type.
Select Type Out and sort Largest to Smallest.
Select all, in Remove Duplicates uncheck all but Name, Date and Type and OK.
Resort and delete index, if desired.

SPD: calculated column with data from another list

I'm in the same situation described HERE.
I'm trying to use Create List Item and Update List Item actions (like suggested in the answer) but without any results.
Could someone kindly explain the procedure mentioned in the answer?
Thank you,
Marcello
I posted an answer there, but here is a copy in case it gets deleted or removed:
lem.mallari's answer is a huge pain unless you can assume that the Amounts in List A never change, since it's not tracking whether an item has already been added to the sum. There is no way for a Workflow to iterate through a SharePoint list, which means there is no easy way to calculate the sum or average of multiple list items.
The correct way to implement this will will require some development. The SharePoint Developer Training (2010, 2013) will actually get you most of the way there: an event receiver should trigger when items are added or changed in Lists A and B that uses SharePoint's API to go through List A and average values by Name, then update all (or just affected) items in List B. Alternatively, you can use JavaScript to display the sum of all entries in List A that have the same name as the item in List B as long as all the data is displayed on your page. If you're handy with XPath and InfoPath, you could add List A as a secondary data source to List B's form and select only applicable items in List A to sum from.
But if we're talking Workflows, here's the "workflow only" method. This was tested and successful in 2010. Create custom List C with the following columns:
Title (string, mandatory, enforce unique values)
TotalItems (integer, mandatory, default 0)
Sum (number, decimal places however you want, mandatory, default 0)
Average (calculated, =IF(TotalItems=0,0,Sum/TotalItems)) (optional)
Replace the Name columns in Lists A and B with lookup columns pointing at List C. Delete the Amount column in List B, instead including the Sum column as an additional column. Add the following columns to List A, and ensure that users cannot change them directly. This can be restricted by making InfoPath forms or by making alternative view and edit forms.
AmountArchive (number, identical to Amount, default 0)
AmountHasBeenSubmitted (yes/no, default no)
Create a Workflow to run each time an item is created or modified in List A. Use these commands (I'm using a list for readability; it was getting ugly when formatted as code):
If Current Item:Amount not equals Current Item:AmountArchive
Set Variable:Item Count to (Data source: List C; Field from source: TotalItems; Find the List Item: Field Title; Value: Current Item:Name(Return field as: Lookup Value (as Text)))
Calculate Variable:ItemCount plus 1 (Output to Variable: ItemCount)
Calculate List C:Sum (similar settings as above; be sure to use Lookup Value (as Text) and not String!) minus Current Item:AmountArchive (Output to Variable: SumWithoutValue)
Calculate Variable: SumWithoutValue plus Current Item:Amount (Output to Variable: NewSum)
If Current Item:AmountHasBeenSubmitted equals No
Set AmountHasBeenSubmitted to Yes
Update item in List C (Set TotalItems to Variable:ItemCount; Set Sum to Variable:NewSum; Find the List Item in the same way of Field:Title; Value: Current Item:Name(Return field as: Lookup Value (as Text))
Else
Update item in List C (don't do anything to TotalItems; use the same logic to set Sum to Variable:NewSum)
Set Amount to Current Item:AmountArchive

Resources