May I know how to write the logic for this in cognos report studio please? - cognos

I have to get an report with recent appointment date for the patient and also BP value from tha Vitals.
In the Vitals there are BP, rr, hr, height etc. But I have to only get the BP for the most recent appointment date. The BP value can be null or not null but I should get the recent appointment date. I am using meta data.

You can either create a Data item:
MAX([Appointment date] for [Patient])
or a filter:
[Appointment date]= MAX([Appointment date] for [Patient])

Welcome Padmavthi!
maximum([BPU Date] for [Patient])
If the null results are getting tricky, try this:
Create a query for the BPU data and a query for the patients
Join the two queries with the following cardinality:
Patients 1.1 to 0.n BPU

Related

How can I split weekly data to monthly using Excel/ Power Pivot?

My Data is in weekly buckets. I want to split the number into a monthly number but, since there is an overlap in days falling in both the months, I want a weighted average of the data in terms of days that fall in each of the months. For example:
Now, in the above picture, I want to split that 200 (5/7*200 in Jan, 2/7 in Feb). How can I do that using Excel/ Power Pivot/ Dax Functions? Any help here is much appreciated.
Thank you!
Assuming your fact table looks something like below. Values are associated with the starting date of the week it occurred.
Although it may actually be a more granular data, having multiple rows for each week with additional attributes (such as identifiers of a person, a store, depending on the business), what being shown below will work the same.
What we need to do first is to create a date table. We can do that in "Design" tab, by clicking "Date Table", then "New".
In this date table, we need to add a column for starting date of the week which the date of each row is in. Set the cursor to "Add Column" area, and input following formula. Then rename this column to "Week Start Date".
= [Date] - [Day Of Week Number] + 1
Now, we can define the measure to calculate the number allocated to each month with following formula. What this measure is doing is:
Iterating over each row of the fact table
Count the number of days for the week visible in the filter context
Add the value portion for the visible days
Value Allocation := SUMX (
MyData,
VAR WeekStartDate = MyData[Week]
VAR NumDaysInSelection = COUNTROWS (
FILTER (
'Calendar',
'Calendar'[Week Start Date] = WeekStartDate
)
)
VAR AllocationRate = DIVIDE ( NumDaysInSelection, 7 )
RETURN AllocationRate * MyData[Value]
)
Result in the pivot table will be looking like this.

How to show previous period sales of items that didn't have sales in current month in Power Pivot?

When displaying prior month sales, I noticed that items with no sales in current month are missing in the Pivot Table output of the data model. However, the grand total sales includes sales of those missing items.
I created a small data model to replicate the issue: 2 tables (1 sales table and 1 calendar table) and it has 1 single DAX formula:
Previous Month Sales:=CALCULATE(sum([Sales]),PREVIOUSMONTH(Sales[Date]))
In the output table, I would have expected 1 more item row for Potatoes, with 0 sales in current month and 31 in previous month.
Is there a way to force-show Potatoes item in the pivot table above when selecting date 24/03/2019? Can this be achieved with DAX formulas?
You need to use the Date field from your Calendar (Date) table, for Time Intelligence to work as you intend:
So change your Previous Month Sales measure to:
Sales Previous Month:=CALCULATE (
SUM ( Sales[Sales] ),
PREVIOUSMONTH ( Calendar[Date] )
)
I'd also recommend creating an Explicit Measure for Sales:
Sales Total:=SUM ( Sales[Sales] )
Now you can recreate your pivot output, using Date field(s) from Calendar in your slicer / filter, and you should get the output you require:

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])

Measure for sum of open positions in accounting (two date columns in source)

I would like to calculate the sum of open positions in a receivables account. The entries in the accounting system provide three relevant columns in the source table to that end:
booking date
due (=pay) date
amount due
I would like to have a measure that I can use for a graph, showing the total of all open positions on each day.
An open position is an amount booked with a booking date before "today" and with a due date after "today".
I tried the following approach in my Power Pivot model (with three calendar tables):
booking date related to "calendar table 1"
due date related to "calendar table 2"
Date columns of "calendar table 1" and "calendar table 2" related to a third "calendar table main"
For that formula I am getting an error message:
Hm, not sufficiently proficient in PowerPivot to solve this problem.
SumAmt:=
SUM( Source_Table[Amount] )
OpenPositions:=
CALCULATE(
[SumAmt]
;FILTER(
VALUES( Source_Table[Booking_Date] )
;Source_Table[Booking_Date] < MAX( Calendar_Main[Calendar_Date] )
)
;FILTER(
VALUES( Source_Table[Due_Date] )
;Source_Table[Due_Date] > MAX( Calendar_Main[Calendar_Date] )
)
)
Your error is pretty self-explanatory. If you use a direct column reference in CALCULATE() you can only reference a single column. You are referencing two, Calendar_Main[Calendar_Date] and either Source_Data[Booking_Date] or Source_Data[Due_Date]. This is simply not allowed, so it throws the error.
The workaround is simply to wrap complex filtering logic in table expressions and use those as arguments to CALCULATE(). Pretty much, unless you are hard-coding a literal predicate for a single column, you should be using some sort of table expression, like FILTER(), as your arguments to CALCULATE().
What we do is call FILTER() twice to check the dates. We use MAX()s because we cannot perform comparisons between column references, we need to perform inequality comparisons between scalars.
Since we're FILTER()ing over Source_Data[Booking_Date] and Source_Data[Due_Date], the references to these are evaluated in row context and refer to the value of the current row in FILTER()'s iteration. The reference to Calendar_Main[Calendar_Date] is just a column reference, so we wrap it in MAX() to get a scalar value for our inequality. The MAX() refers to the current filter context coming in from the pivot table, which would be the current row label or column label.
If you aggregate to the month level, this will give you essentially the closing balance, since we're using MAX()s. At the month level the value will be identical to that on the last date of the month.
Finally, with the inequalities you've set up, you're ignoring anything opened on the current day or due on the current day. I'd expect you want [Booking_Date] <= [Calendar_Date] and [Due_Date] > [Calendar_Date].

Show all data in the same row in Framework Manager 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.

Resources