Cognos: create date item as percentage of total - cognos

I am quite newbie in cognos. I wonder how I can create a variable as percentage from the total.
I have the following table containing a variable named compliant which can either be Y or No.
Y
N
Total
percentage_Y_of_total%
1
3
4
25%
I created the Y and N variable with
case when Complaint_VAR ('Y') then 'Compliant' else 'Non-Compliant' end
My question: How do I create percentage_Y_of_total variable? How do I create a data item as percentage of the total split by case when clause?

Go to query explorer. Tool box. Drag data item to the details to create custom expressions
Use function total and define the scope, let's call the data item Y_Total. For example the expression would look like:
Total(Y for company, year, month)
Create another data item Overal_Total that gets the total rows of data
Create a calculation data item called percentage_Y_of_total% that takes Y_Total divided by Overal_Total

Related

I need to pull a complete row from one excel sheet to another escel sheet, based on a cell value

I have 2 Excel worksheets. In the first I have a table that has a column named "Sales Order" and "SO Item" of each row (product) plus some other columns. In this table I concatenate "Sales Order" and "SO Item" so that I have Sales Order parent (xxxxxxx00) and also Sales Order childs (xxxxxxx01, xxxxxxx02,...,xxxxxxx09). However, in the second worksheet I also have the "concatenation" column but only contains Sales Order parents. How can I pull the whole rows containing the childs of each parent from worksheet 1 to worksheet 2?
I've tried to do it using VLOOKUP but this only returns a single child value (xxxxxxx001) and also its not returning the whole row where this code is located
Table 1 is:
Sales Order
SO Item
Concatenation
Material Description
Feas Plan Date
2503319449
100
2503319449100
SYS-7210 SAS-Mxp
Bundle Header
2503319449
101
2503319449101
PS-7210 SAS-T/Mxp
1/31/2023
2503319449
102
2503319449102
SYS-7210 SAS-Mxp2VDC
Global Allocation
2503319449
200
2503319449200
OS-7210 SAS-Mxp
1/31/2023
Table 2 is:
Sales Order
SO Item
Concatenation
Material Description
Feas Plan Date
2503319449
100
2503319449100
SYS-7210 SAS-Mxp
Bundle Header
2503319449
200
2503319449200
OS-7210 SAS-Mxp
1/31/2023
I want Table 2 to extract the missing "Concatenation" items from Table 1.
It is not clear from the question, how to present the output. I assume Table2 is your lookup table. Based on the input data, you need to return the entire Table1, I assume your Table1 has more data in your real case, and you want to extract just the information based on the lookup table. In the way you construct the concatenation, for the lookup it is only necessary the SO Item column values. Put on G2 the following formula:
=LET(tbA, A3:E4, tbB, A9:E12, soA, 1*INDEX(tbA,,2), soB, 1*INDEX(tbB,,2),
DROP(REDUCE("", soA, LAMBDA(ac,x, LET(f,
FILTER(tbB, (soB >= x) * (soB < x+100),""), IF(#f="", ac, VSTACK(ac,f))))),1))
Here is the output:
The condition:
IF(#f="", ac, VSTACK(ac,f))
It is just to prevent empty result from the FILTER output (f), it is not really necessary if you want to include the parent (condition: soB >= x as it is in the formula), but if you want to exclude it (soB > x) then you need it. Check my answer to the question: how to transform a table in Excel from vertical to horizontal but with different length on how to use DROP/REDUCE/VSTACK pattern. I convert to numeric values (multiplying INDEX by 1) the value of SO Item column, in case the input data is in text format, otherwise it is not necesary.

How can I extract a total count or sum of agents who made their first sale in a specified month?

I am trying to extract some data out of a large table of data in Excel. The table consists of the month, the agent's name, and either a 1 if they made a sale or a 0 if they did not.
What I would like to do is plug in a Month value into one cell, then have it spit out a count of how many agents made their first sale that month.
Sample Data and Input Output area
I found success by creating a secondary table for processing a minif and matching to agent name, then countif in that table's data how many sales months matched the input month. However I would like to not have a secondary table and do this all in one go.
=IF(MINIFS(E2ERawData[Date Group],E2ERawData[Agent],'Processed Data'!B4,E2ERawData[E2E Participation],1)=0,"No Sales",MINIFS(E2ERawData[Date Group],E2ERawData[Agent],'Processed Data'!B4,E2ERawData[E2E Participation],1))
=COUNTIFS(ProcessedData[Month of First E2E Sale],H4)
Formula in column F is:
=MAX(0;COUNTIFS($A$2:$A$8;E3;$C$2:$C$8;1)-SUM(COUNTIFS($A$2:$A$8;"<"&E3;$C$2:$C$8;1;$B$2:$B$8;IF($A$2:$A$8=E3;$B$2:$B$8))))
This is how it works (we'll use 01/03/2022 as example)
COUNTIFS($A$2:$A$8;E3;$C$2:$C$8;1) This counts how many 1 there are for the proper month (in our example this part will return 2)
COUNTIFS($A$2:$A$8;"<"&E3;$C$2:$C$8;1;$B$2:$B$8;SI($A$2:$A$8=E3;$B$2:$B$8)) will count how many 1 you got in previous months of the same agents (in our example, it will return 1)
Result from step 2, because it's an array formula, we sum up using SUM() (in our example, this return 1)
We do result from step 1 minus result from step 3 (so we get 1)
Finally, everything is inside a MAX function to avoid negative results (February would return -1 because there were no sales at all and agent B did a sale on January, so it would return -1. To avoid this, we force Excel to show biggest value between 0 and our calculation)
NOTE: Because it's an array formula, depending on your Excel version maybe you must introduce pressing CTRL+ENTER+SHIFT
If one has got access to the newest functions:
=LET(X,UNIQUE(C3:C9),VSTACK({"Month","Total of First time sales"},HSTACK(X,BYROW(X,LAMBDA(a,SUM((C3:C9=a)*(MINIFS(C3:C9,D3:D9,D3:D9,E3:E9,1)=C3:C9)))))))

Excel Formula to calculate SD and SUMSQ based on 4 conditions. 2 of the conditions will determine from which column the data will be taken from

I am having problems building two formulas with 4 conditions to return the Sum of Squares and the Standard Deviation from a dataset:
First two conditions. Located in data validation cells outside of the data range:
KPI
Period of time
Second two conditions:
Campaign Name
Player Group = Target Vs Control
The basic idea is that a player will generate a value for a series of KPIs over different periods of time (7,14 and 28 days). Therefore the structure of the data sets will be defined as:
Columns:
Player ID
Campaign ID
Player Group: Target or Contol
Rest of the columns: Combinations of a KPI and a given period of time.
The objective is to calculate the SD and SUMSQ of a subset of data based on the following restrictions: the KPI, the period of time, the Campaign ID and the Group of the player. As the dataset is built, the conditions "KPI" and "Period" will determine the column from which the data is going to be taken and the conditions "Campaign" and "Player Group" will act as row filters.
I have tried the following... with little hope, since I don't even expect that an array formula can be nested in an "if" function:
=IF(AND(Test!$J$9="STAKES",Test!$M$9=7),STDEV.S(IF(DATA!$A$2:$A$9237=Test!$B$13,DATA!$AD$2:$AD$9237,0)))
Can someone come up with a solution, please?
It looks like you are getting close. The "0" is where your next "if statement" will go.
So if the first "AND" condition is false the next "if statement" in the position where "0" was will execute.
Instead of $J$9="STAKES" and $M$9=7 I changed it to $J$9="TACOS" and $M$9=9000.
=IF(AND(Test!$J$9="STAKES",Test!$M$9=7),STDEV.S(IF(DATA!$A$2:$A$9237=Test!$B$13,DATA!$AD$2:$AD$9237,IF(AND(Test!$J$9="TACOS",Test!$M$9=9000),STDEV.S(IF(DATA!$A$2:$A$9237=Test!$B$13,DATA!$AD$2:$AD$9237,0))))))

Calculated column which references its previous value and current value

I have a requirement where I am creating a calculated column. This column needs to use its own previous value and also its current value (i.e. to perform a cumulative calculation).
I know this is possible in Tableau by using the function
PREVIOUS_VALUE(-1)
so I can do something like
x (calc) = sum(x(calc) + PREVIOUS_VALUE(-1))
How can this be performed in Spotfire? In other words, what is the equivalent Spotfire function to
PREVIOUS_VALUE(-1) (from Tableau)
Here is the equivalent implementation on excel. Where [WDVpt2] is the calculated field.
This is done with an OVER function. You can read about them from the Tibco Documentation. The formula you are looking for is:
(Sum([x]) over (AllPrevious([x]))) - [x]
Uses all nodes, including the current, from the start of the level.
This can be used to calculate the cumulative sum.
I was able to achieve this by the following approach. Its a limitation of Spotfire that a calculated column can not refer its value at the previous node.In tableau Lookup and Previous_value supports this feature(not to be confused with Previous() of Spotfire which can be applied on a static column [x] so [X_Calc]= [X_Calc]+ [X_Calc] over(AllPrevious([ROWID])) is not possible
Step1:Create a ROW ID column which is based on perdiod Rowid([YEAR])
Step2:Breaking the result for each row into a separate calculated column so first row value
First(Sum([WDVpt1]) over (AllPrevious([RowID])) - (Sum([WDVpt1]) over AllPrevious([RowID])) * [Policy rate])) over (AllPrevious([RowID])))
Step3: Create columns for remaining periods(3 to 16) by using the previous calculated column Eg:- column for node 3 will use [WDVpt2_Year2] column for node 4 will use [WDVpt2_Year3] and so on Sum((case when [RowID]=2 then [WDVpt1] end) + Min([WDVpt1]) over ([RowID]) - (((case when [RowID]=2 then [WDVpt1] end) + Min([WDVpt2_Year2]) over (intersect([asset class code],[RowID]))) * [Policy rate])) over (AllPrevious([RowID])))
Step4: Write a case statement to generate one single column
case when [RowID]=2 then first([WDVpt2_Year2]) when [RowID]=3 then first([WDVpt2_Year3]) when [RowID]=4 then first([WDVpt2_Year4]) when [RowID]=5 then first([WDVpt2_Year5]) when [RowID]=6 then first([WDVpt2_Year6]) when [RowID]=7 then first([WDVpt2_Year7]) when [RowID]=8 then first([WDVpt2_Year8]) when [RowID]=9 then first([WDVpt2_Year9]) when [RowID]=10 then first [WDVpt2_Year10]) when [RowID]=11 then first([WDVpt2_Year11]) when [RowID]=12 then first([WDVpt2_Year12]) when [RowID]=13 then first([WDVpt2_Year13]) when [RowID]=14 then first([WDVpt2_Year14]) when [RowID]=15 then first([WDVpt2_Year15]) when [RowID]=16 then first([WDVpt2_Year16]) end as [WDVpt2]

Need an Expression to Split a DateRange column into 3 bins

I want to represent count of ID's wrt to Daterange column. I tried to split it into bins but there was option to split into no of parts and not as 3 differnt date values.I want to split the Date Range column into 3 parts so that i  can represent the data in a bar chart as Current,Pat and Future data. Each of the 3 bins are represented as:
1.Current - Count of ID for Current month[Dec 2016]. The data for current month should be dunamically calculated since if the next month comes the data should point to that by the dynalic calculation
2.Past - Count of ID for Data less than current month[Data < Dec 2016]. I need to be able to dynamically change the no of months using custom expression so that user can chnage th e no of months it goes back to. Need the expression in such a way that it can be set by a custom expression ,if not the nos can be changed at the expression
3.Future - Count of ID for Data greater than current month[Data  Dec 2016]. I need to be able to dynamically change the no of months using custom expression so that user can chnage th e no of months in the future. There will be future dates available since it is a data for manintenance done in the future time.
This 3 data needs to be as a custom/binned column so that the data is represented as shown in the attached picture.
You just need to create a calculated column...
case
when DatePart('month',[DateColumn]) = DatePart('month',DateTimeNow()) and DatePart('year',[DateColumn]) = DatePart('year',DateTimeNow()) then "Current"
when [DateColumn] < DateTimeNow() and [DateColumn] >= DateAdd('month',${NumOfMonthsBack} * (-1),[DateColumn]) then "Past"
when [DateColumn] > DateTimeNow() and [DateColumn] <= DateAdd('month',${NumOfMonthsAhead},[DateColumn]) then "Future"
end as [MonthRange]

Resources