Show all data in the same row in Framework Manager Cognos - cognos

I'm using IBM Cognos Framework Manager/Report Author 10.2.1
The Data looks like the following for two rows:
**Case ID Activity Date Updated**
11111 Bill Paid 09/25/2015
11111 Received Bill 08/01/2015
On my report, I need to show the following for the same exact Case:
**Case ID LAST Activity LATEST ACTIVITY Date Updated**
11111 Received Bill Bill Paid 09/25/2015
Received Paid needs to show in the same Row showing the latest
information with the 09/25/2015 Date.
Not sure how to do this in the report or even Framework Model?

This is tricky but a worthy question as you come across this type of data modeling regularly. I can give you a solution in the report.
The two bits you need to figure out is the maximum 'Date Updated' for each ID and the next to maximum 'Date Updated' for each ID.
Create a new data item called 'Max Date' with the following expression:
maximum([Date Updated] for [Case ID])
Create another new data item called 'Next Max Date' with the following expression:
maximum(
CASE
WHEN [Date Updated] <> [Max Date] THEN [Date Updated]
ELSE null
END
for [Case ID])
Create another data item called 'Latest Activity' with the following expression:
CASE
WHEN [Date Updated] = [Max Date] THEN [Activity]
ELSE null
END
Create yet another data item called 'LAST Activity' with the following expression:
CASE
WHEN [Date Update] = [Next Max Date] THEN [Activity]
ELSE null
END
Set the 'Aggregate Function' property of both 'Latest Activity' and 'LAST Activity' to 'Maximum'.
Summary
We calculate the maximum date for each Case ID. Next we use a CASE statement to exclude the rows that correspond to the max date and then get a maximum for each Case ID of all other rows. We create a new data item that will spit out the Activity if the date matches the max date otherwise null is emitted. We create a second data item that outputs the Activity if the date matches the next to max date otherwise spits out null. We set the aggregate function for both to 'Maximum' which has the effect of getting rid of any null values in those columns through the auto-group and summarize process. This leaves us with two new columns on each row showing the activity of the latest and the one before that.

Related

Excel VBA Power Query - How to create a query that dynamically returns only the sale's rows of the last minute?

I have a comma separated csv file with the following structure:
Col Headers:
ProdDate, ProdTime, OLEDATETIME, ProdBuyPrice, ProdSellPrice, ProdBoughtQTY, ProdSoldQTY, etc
09/21/2019, 13:54:22, 43729.5801, 12.45, 12.61, 8, 9, etc.
This CSV file is atualized many times per minute (5 to 70 times per minute) meaning that it can have 5 to 70 lines within the last minute of sales, then I can't fix an arbitray fixed number on "mantain first lines" to return only the rows that arrived in the last minute and I never did this before with Power Query. So I need an finished recipe to do this, but my googling resulted nothing until now.
Any suggestion?
This is an example of how you can identify a dynamic row number. In this example, we have a table that shows fruit sales by store. We want to create a query that returns the highest number of bananas sold.
This is what our data table looks like.
Step 1 - Add an index column starting from 1. This assigns row numbers.
Add Column > Index Column > From 1
Step 2 - Filter and Sort the data.
Remove any columns that are unnecessary.
Filter the Item column for Bananas.
Sort the Values column in descending order.
Right-click on the first value in the Index column and choose Drill-Down.
RESULT
Now you have a dynamic row #. You could also instead choose the value itself to return the sales instead of the index. To apply this to other scenarios, just keep filtering and sorting until you get to the result you need.
This is how you filter a time column for records occurring in the latest one minute of times.
let
Source = Excel.CurrentWorkbook(){[Name="t_DatesAndTimes"]}[Content],
ChangedTypes_ColData = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Time", type time}}),
AddCol_DateAndTime = Table.AddColumn(ChangedTypes_ColData, "Date and Time", each [Date] & [Time], type datetime),
LatestTime_ofReport_MinusOneMinute = List.Max(AddCol_DateAndTime[Date and Time])-#duration(0,0,1,0),
FilterRows_KeepTimesInLastMinute = Table.SelectRows(AddCol_DateAndTime, each [Date and Time] >= LatestTime_ofReport_MinusOneMinute)
in
FilterRows_KeepTimesInLastMinute
Data Table needing to be filtered
Table filtered for time in the last minute of times listed in the report.

Power Query - The field 'xxx' of the record wasn't found

I want to add a new column to a source of data.
The new column's value is based on the data of the current row (To Resolved date and From Activated date) as well as data from another query (Calendar). Here is the a screenshot of the source data I am working on:
I am trying to get the number of rows of the other source (Calendar) that are within the range [From Activated date, To Resolved date]. For now, I have this formula for the new column (without the counting yet):
= Table.SelectRows(Calendar, each _[Date] >= [From activated date] and _[Date] <= [To Resolved date])
However, it does not work because Power Query does not find the columns From Activated date and To Resolved date in the Calendar query.
Expression.Error: The field 'From activated date' of the record wasn't
found.
Details:
Date=2017-01-01
Year=2017
MonthNumber=1
MonthName=January
Day=1
Weekday=1
WorkingDays=0
Question
How can I get the current values of From Activated date and To Resolved date for the current row ?
Add another query as a function - in this case, I named it 'CalendarRows':
(StartDate, EndDate) =>
let
Source = Table.RowCount(Table.SelectRows(Calendar, each [Date] >= StartDate and [Date] <= EndDate))
in
Source
Now add a column to your data table, referencing this function:
= Table.AddColumn(#"Previous Step", "Calendar Rows", each CalendarRows([From activated date], [To Resolved date]))

Showing Last Sold Date In a Netsuite ITEM Saved Search

I've created a search that shows current inventory on hand, their purchase price, and a formula that multiplies the two to have current value.
In the results field I want to have a column that shows the last time an item was on a sales order. but i am coming up short. Is there a way to do this?
Filter Criteria
Results Criteria
Criteria -
Inactive - FALS
Type - Inventory Item
Transaction Field: Type - Sales Order
Available - Is greater than 0
RESULTS -
Name - (Summary Type Group)
Description - (Summary Type Group)
Available - (Summary Type Count)
Transaction Fields - Date (Summary Type Maximum)
Did you create the saved search from the Item Record or Transaction Record?
If you created it from the Transaction Record then you will want to make sure to use the Date Field and Summary Type (Results tab) as Maximum.
Field = Date
Summary Type = Maximum
If you created the saved search from the Item Record you will need to use the Transaction Fields... table join to bring in the Transaction Date field.

If each record has an open and close date, how to display active records over time

If each record has an open and close date, how I can to display number of active records on last day of each quarter.
I am using IBM Cognos Analytics 11.0.9 and I am relatively new... Please Just a hint were to go... Thank you.
Assuming that the Close Date data item is null or a specific dummy value when the item is active, you can simply count rows where that condition is met.
TOTAL(
CASE
WHEN [Active Date] <= current_date AND [Close Date] is null
THEN 1
ELSE 0
END
for report)
If you need to aggregate the count for something other the entire report, change the 'for' clause to list out the data items you want to roll the count up to.
For example, to roll the count up to a data item named [Item]:
TOTAL(
...
...
...
for [Item])

Previous Year row in measurement, DAX formula

I have the following table:
Year test is the list of previous year:
=SUMX(Datasrc;Datasrc[Year]-1)
How do I get something similar for "Calculated field 1"? In other words, I want to get the previous "Price/kg" so it match column C, "Year test".
I have tried with the formula from Find rows relative to current row's value in excel (DAX):
=SUMX(
FILTER(Datasrc; EARLIER([Year]) = [Year] + 1 );
Datasrc[C_Total Asset Per Share]
)
But only get: "Calculation error in measure 'Datasrc'[Calculated field 2]: EARLIER/EARLIEST refers to an earlier row context which doesn't exist."
The column A is [Year]
DAX has time intelligence functions built in, so it's fairly easy to do what you'd like using the SAMEPERIODLASTYEAR function.
First you need a date table joined to your fact table. Then just do
CALCULATE ( [Base Measure], SAMEPERIODLASTYEAR(DateTable[Date]) )

Resources