How to Filter individual columns within a Cognos Report - cognos

All data are coming from one table. Date is based on the creation_date field of the table. I would like to create a report similar to the example below:
No. Prior to No. On
10/01/2015 10/1/2015 Total No.
a 5 1 6
b 10 3 13
c 1 0 1
I could not figure out how to display the combine results on the same "Report Page". I have to create 2 report pages one is for the prior date and the other is for the date "on".

Ok. If I understand your data correctly do this.
In your report create query with query items:
Type (a,b,c etc)
[No. Prior to 10/01/2015] with Aggregate Function = 'Total' and with expression
case when creation_date < to_date('10/01/2015', 'DD/MM/YYYY')
then 1 else 0 end
[No. On 10/1/2015] with Aggregate Function = 'Total' and expression
case when creation_date >= to_date('10/01/2015', 'DD/MM/YYYY')
then 1 else 0 end
[Total No.] with expression
[No. Prior to 10/01/2015] + [No. On 10/1/2015]
And create simple table with this values.
Or you can try to do it with crosstab.

Related

DAX: Using Calendar Month as a column and as a criteria for counting records based on current row

So I have the following pivot table report through my data model. I want my measure 'Branches
Per Cluster' to consider the current column of month or year.
I have the following tables aside from a generated calendar table, these two below are related by 'CODE'.
A dim table named 'Branch Profiles'
CODE
AREA
CLUSTER
DATE OPENED
AAA
Area 1
Cluster 1
01/05/1990
AAB
Area 1
Cluster 1
05/03/2022
ABA
Area 2
Cluster 1
01/03/2005
BAA
Area 3
Cluster 2
01/03/2024
A fact table named 'BasicData'
CODE
Volume
Value
Date
AAA
1000
10000
06/01/1990
AAB
2000
20000
06/01/2020
ABA
3000
30000
06/01/2005
BAA
4000
40000
06/01/2008
This is what I currently have for my Branches Per Cluster measure which might be obvious for experienced users that is syntactically wrong though I believe it shows what I was trying to do as
I'm not quite sure how to reference the column as a filter. Basically, I just want to count the Branches ("CODE") for the specific area that have a date opened before the month specified by the column filters.
=CALCULATE(
DISTINCTCOUNT('Branch Profiles'[CODE]),
ALLEXCEPT('Branch Profiles',
'Branch Profiles'[AREA],
'Branch Profiles'[CODE]
),
YEAR('Branch Profiles'[DATE STARTED]) <= 'Calendar'[Year],
MONTH('Branch Profiles'[DATE STARTED]) <= 'Calendar'[Month Number]
)
Here is the proper code for the Measure that I was trying to accomplished. What I was missing earlier was a way to reference the current value of the Year and Month columns (Context Filters) and use it as a criteria on the [Date Started] column to get the count on [CODES] that are opened on or before currently specified Month or Year.
If this was done in PowerBI the solution would have involved the function named "SELECTEDVALUE" however, the logic can still be implemented in Excel through the longer syntax shown below in my measure.
VAR cur_year =
IF (
HASONEVALUE('Calendar'[Year]),
VALUES('Calendar'[YEAR])
)
VAR cur_month =
IF (
HASONEVALUE('Calendar'[Month]),
VALUES('Calendar'[Month Number])
)
RETURN
IF(
NOT ISBLANK([Send Volume]),
CALCULATE(
DISTINCTCOUNT(Branch Profiles[CODE]),
ALLEXCEPT('Branch Profiles',
'Branch Profiles'[AREA],
'Branch Profiles'[CODE]
),
'Branch Profiles'[DATE STARTED] < DATE(cur_year, cur_month + 1, 1)
)
)

Rank, group and set a label in Spotfire table

I have two column [Clients] and [Sales], I'd like to create a new column containing a scoring (from 1 to 5) for each "Client" in terms of Sales.
I want to make a ranking of [Sales] and split it, uniformly in 5 groups, then set a label 1 for the highest [Sales], 2 for the second group, etc...
Does someone have an idea of an expression to use ?
You can use the percentile function in conjunction with a case statement. In the screenshot below, I created 5 calculations to find the 20th, 40th, 60th, and 80th percentiles and then created a case statement to rank based on those values.
Percentile calculation:
Percentile([Sales],20)
Case statement:
case
when [Sales]<[20th Percentile] then 1
when ([Sales]>=[20th Percentile]) and ([Sales]<[40th Percentile]) then 2
when ([Sales]>=[40th Percentile]) and ([Sales]<[60th Percentile]) then 3
when ([Sales]>=[60th Percentile]) and ([Sales]<[80th Percentile]) then 4
when [Sales]>=[80th Percentile] then 5
else NULL
end
See attached screenshot
Data sample and calcs

Excel sumifs until a new value in column

I have some data that looks like:
Day Result
1-Nov 1
0
1
2-Nov 1
3-Nov 0
0
4-Nov 1
There are other columns with data. I only have the date once as the data is displayed graphically in a time series.
Now I'd like to setup a summary table that aggregates each day. I cannot use sumifs because the date is only in the data once.
How could I write a calculation such that excel sees a2 has a value so sums b2,b3,...bi until ai has a value.
Preferably not vba, never learned it and want to do this in excel rather than R or Python.
EDIT:
I am specifically looking at how to do calculations on the result column grouped by each date. Blank cells should be considered the same date. So when excel sees 1-Nov it then does a calculation (i've said sum but any we can extend to) on 1,0,1 and then stops and a new calculation is done for Nov-2.
IMHO, instead of using a table like this:
Day Result
01/nov 1
0
1
02/nov 1
03/nov 0
0
04/nov 1
You should populate the "Day" column and use a pivot table to summarize the results.
I.e.:
Day Result
01/nov 1
01/nov 0
01/nov 1
02/nov 1
03/nov 0
03/nov 0
04/nov 1
And the pivot table:

How to create a ranged frequency table using Excel Cube functions

What I want is to create something like this (see image) in Excel that pulls in the frequency of my chosen category from a table within my PowerPivot data model. The output would also need to be dynamically filtered via a cell reference.
Using the below data set as an example:
Week 1 A
Week 1 A
Week 1 A
Week 1 A
Week 1 A
Week 1 B
Week 1 B
Week 1 C
Week 1 D
Week 2 A
Week 2 A
Week 2 A
Week 2 A
Week 2 A
Week 2 A
If I filtered to Week 1 through my set expression, the following output would be produced
1 2
2-4 1
5+ 1
However, if filtered to Week 2, this output would be produced
1 0
2-4 0
5+ 1
I say 'set expression' because I am assuming the way to do this is through the CUBESET function possibly with a MDX FILTER function and the CUBESETCOUNT functions though I am open to other suggestions. Even though the example doesn't show it, I need the expression to filter multiple dimensions from my cube, in particular, date, which is found in my calendar table.
I also understand that I could create specific measures within PowerPivot to handle this (sample formula below), but I would like to know if this is possible via the CUBESET function.
Freq (5+):=CALCULATE(
DISTINCTCOUNT([myColumn]),
FILTER(myTable,
COUNTROWS(FILTER('myTable', [myColumn] = EARLIER([myColumn]))) >=5 )
)
I am also open to creating a helper column within my Powerpivot table.
Thanks,

how to count of issue with open status in spotfire

I need to calculate count of issue ID for each month with open status.
I have below 3 columns-
Issue_ID
Issue_Open_Date
Issue_Closed_Date
Issue_ID Issue_Open_Date Issue_Closed_Date Open_Issue_Count(required output)
IS_10 11/11/2014 1/5/2015 3
IS_11 11/12/2014 12/14/2014
IS_12 11/13/2014 11/15/2014
IS_13 11/14/2014 3/5/2015
IS_1 12/1/2014 12/15/2014 4
IS_2 12/2/2014 2/10/2015
IS_3 12/3/2014 1/15/2015
IS_4 1/1/2015 2/10/2015 4
IS_5 1/2/2015 3/11/2015
IS_6 1/3/2015 1/22/2015
IS_7 2/1/2015 3/5/2015 3
IS_8 2/2/2015 2/2/2015
IS_9 2/7/2015 2/28/2015
IS_14 3/1/2015 4/5/2015 1
Based on above table, i need a count of open status of each month.
lets suppose in December i need to count than it should check in dec and nov month.
If any issue is closing in same month, it mean that is not in open stage,
Basically for each month it should check for their records also and previous month records also.
Required output is below-
Nov- 3
Dec- 4
Jan-4
Feb-3
march-1
So... I have a way but it's ugly. I'm sure there's a better way but I spent a while banging my head on this trying to make it work just within Spotfire without resorting to a python script looping through rows and making comparisons.
With nested aggregated case statements in a Cross Table I made it work. It's a pain in the butt because it's pretty manual (have to add each month) but it will look for things that have a close date after the month given and an open date that month or earlier.
<
Sum(Case
when ([Issue_Closed_Date]>Date(2014,11,30)) AND ([Issue_Open_Date]<Date(2014,12,1)) then 1 else 0 end) as [NOV14_OPEN] NEST
Sum(Case
when ([Issue_Closed_Date]>Date(2014,12,31)) AND ([Issue_Open_Date]<Date(2015,1,1)) then 1 else 0 end) as [DEC14_OPEN] NEST
Sum(Case
when ([Issue_Closed_Date]>Date(2015,1,31)) AND ([Issue_Open_Date]<Date(2015,2,1)) then 1 else 0 end) as [JAN15_OPEN] NEST
Sum(Case
when ([Issue_Closed_Date]>Date(2015,2,28)) AND ([Issue_Open_Date]<Date(2015,3,1)) then 1 else 0 end) as [FEB15_OPEN] NEST
Sum(Case
when ([Issue_Closed_Date]>Date(2015,3,31)) AND ([Issue_Open_Date]<Date(2015,4,1)) then 1 else 0 end) as [MAR15_OPEN]>
Screenshot:
As far as doing it with python you could probably loop through the data and do the comparisons and save it as a data table. If I'm feeling ambitious this weekend I might give it a try out of personal curiosity. I'll post here if so.
I think what makes this difficult is that it's not very logical to add a column showing number of issues open at a point in time because the data doesn't show time; it's "one row per unique issue."
I don't know what your end result should be, but you might be better off unpivoting the table.
unpivot the above data with the following settings:
pass through: [Issue_ID]
transform: [Issue_Open_Date], [Issue_Closed_Date]
optionally rename Category as "Action" and Value as "Action Date"
now that each row represents one action, create a calculated column assigning a numeric value to the action with the following formula.
CASE [Action]
WHEN "Issue_Open_Date" THEN 1
WHEN "Issue_Closed_Date" THEN -1
END
create a bar chart with [Action Date] along the X axis (I wouldn't drill further than month or week) and the following on the Y axis:
Sum([Action Numeric]) over (AllPrevious([Axis.X]))
you'll wind up with something like this:
you can then do all sorts of fancy things with this data, such as show a line chart with the rate at which cases open and close (you can even plot this on a combination chart with the pictured example).

Resources