Spotfire : Weighted Percentage Calculation in BarChart - bar-chart

I have this set of data :
Kind Weight
A 3
A 3
A 3
B 2
B 2
C 1
I would like to create a Spotfire barchart representing the contribution of distinct Kind column values. The expression provided by Spotfire in this case is :
Count() / THEN [Value] / Sum([Value]) OVER (All([Axis.X]))
But I would like to divide this by the value of the Weight column. As Spotfire asks for an aggregating method I tried this unsuccessfully :
Count() / First([Weight]) THEN [Value] / Sum([Value]) OVER (All([Axis.X]))
For the record, I am not using a calculated value because my purpose is to have a dynamic BarChart.
Thanks in advance.

Based on your desired logic, you can use this on your VALUE AXIS of your Bar Chart:
UniqueCount([Kind]) / UniqueCount([Kind]) OVER (All([Axis.X]))
This will work unless the Weight doesn't equal the Count of Kind
If your Weight could change, for example if Kind A had a weight of 2 instead of 3 but still had 3 rows, you can accomplish your logic by doing this:
Insert a calculated column: Count([Kind]) OVER ([Kind]) / Max([Weight]) OVER ([Kind]). Name this column WeightedWeight
Use this formula on the VALUE AXIS of your bar chart Max([WeightedWeight]) / UniqueCount([Kind]) OVER (All([Axis.X]))

Related

SSRS, return rows into a grid layout

I have a dataset that I need to arrange into a grid on a page (export to pdfs) as a customer report. Each row in my dataset needs to display as a cell. Each page would have roughly 3 records displayed as columns and then 4 rows of records. e.g. a (3x4 grid), being 12 records per page.
Right now I am using a matrix to display my results, but I cannot find how to get my matrix to start a 2nd row after 3 columns are generated.
Is this feasible or should I find a different solution to create these reports?
I was thinking may be if I had row groups to use, but not sure how to create a column that creates a repeating result 3 times then adds 1 to the next 3 results in my query. 111,222,333,444 and that could be my row grouping?
Here's what I use in a matrix to create a grid of columns from a single cell.
Add a ROW_NUMBER field to the dataset query and subtract 1 with the ORDER BY using the field to be ordered by.
ROW_NUMBER()OVER(ORDER BY DISPLAY_NAME) - 1 AS ROW_NUM
Add Calculated Fields to the dataset using the ROW_NUM.
Call the first COLUMN and MOD row_num by 3 to get values or 0 - 2 for the column number:
=Fields!ROW_NUM.Value MOD 3
Call the second calculated field ROW and get the INT of ROW_NUM divided by 3 to get the row number for the record:
=INT(Fields!ROW_NUM.Value / 3)
Then the matrix would have the Column grouping (and sorting) based on the COLUMN field and the Row grouping on the ROW field.
You could use a parameter as the number of columns (3) to make it easy to change.

How to take % value for Line graph for series Groups ?/How to plot graph by sql table?

Approach 1:How to take % value for Line graph for series Groups?
I am setting up a ssrs report like with x axis(Category Group) as Finished Week, QualityPercent( as Series groups-RFT%,REwork%,Scrap%) and Values as Sum of Quantity.
In the above graph the quatities are shown in percentages based upon weeks(the actual result whose plot values are given at left side of image). Respective tables structure:
But I am getting the chart like this
Here the y axis is not plotting well asper the category values, sometimes shoots upto 250%!! or 1400% !!! (this is embarrassing).
For the above graph i used expression as:
IIF(Sum(Fields!QTY.Value,"Chart11_SeriesGroup"),Sum(Fields!QTY.Value)/Sum(Fields!QTY.Value, "DataSet_Production"),0)
What i am missing? I even used #Percent. Kindly help me.
Approach 2: How to plot the ssrs graph using below result from sql query?
FinishedWeek QualityPercent QTY Percentage
1 Rework (%) 844 0.109724
1 RFT (%) 6811 0.885465
1 Scrap (%) 37 0.004810
2 Rework (%) 742 0.094618
2 RFT (%) 7096 0.904871
2 Scrap (%) 4 0.000510
After much work done with second approach, I wrote the separate query for the above table
asper the link:
Calculating percentage within a group
select t1.FinishedWeek,t1.QualityPercent,Sum(QTY) as QTY,Sum(QTY)/ t2.TOTAL_QTY as Percentage from #temp
AS t1
JOIN (
select FinishedWeek,Sum(QTY) as TOTAL_QTY from #temp
group by FinishedWeek
) AS t2
ON t1.FinishedWeek= t2.FinishedWeek
group by t1.FinishedWeek,QualityPercent,t2.TOTAL_QTY
From above query , took the Finished Week as Category, QTY as Values, and QualityPercent as Series Groups

SSRS - grouping with ceiling

I'm creating a SSRS-report where I need to group my values and do another grouping based on the grouped values. Then I also want to limit the records on each row.
Now my table look like this (but with maybe 50 values):
A
A
A
B
C
C
D
E
E
F
(ignore the bullets, it was the only way to get the values vertical)
I want my table to fit in one page and become horizontal and be grouped.
The result I'm after look like this:
A, B, C,
D, E, F
I writing this in MDX because I need to have data direct from the cube.
I would have a great solution if i didn't have to group the values together.
It's was to use the ceiling-function (ceiling(rownumber(nothing) mod 6)) in ColumnGroup and (=ceiling(rownumber(nothing) / 6)) in RowGroup.
Has someone a solution, maybe a nested expression to both group the values and then do the ceiling trick?
Perhaps you can add a calculated field to the dataset, GroupID, with a value based on the position in the alphabet and your paging requirement.
For example :
Letter GroupID
A-F 1
G-L 2
M-Q 3
Next you can group similar to below.
Column Group 1 Expression = GroupID
Column Group 2 Expression = Letter
You may wish to place a page break after group for Group1 to force repeats on a new page.

Access query - Percentage

I have a table which tooks like this:
ID_1 Total Active Inactive
124507 4 1 3
124519 4 0 4
124521 4 2 2
I would like to add a column at the end, which would tell me which percentage of the the total are active?
like:
ID_1 Total Active Inactive %
124507 4 1 3 25
124519 4 0 4 0
124521 4 2 2 50
Format(((active) / (total)), Percent)
Reference: http://www.techonthenet.com/access/functions/numeric/format.php
Make a query in query design. Include the table you already have. Drag all the fields from your table to the bottom of the screen where you can put fields to include them in the query. In the next empty box, put:
NameofNewField:Format((tablename.Active)/(tablename.Total), Percent)
This will create a new field in your query, with NameofNewField being the name (change it to whatever you want, but I wouldn't recommend "%"). Also be careful of reserved words, because "Percent" is a reserved word and you'll get an error if you wanted to make that the field name. "tablename" is just the name of your original table.
I included "Format()" in the formula because that way you can just make the query with no other editing, but the better way is to format the field you are making into a percentage into a field that only allows percent, because personally I have problems with Format() sometimes. You can change the field by putting your cursor in the box where you just wrote your formula, then it should show field properties on the right side of the screen where you can change the field to a percent field.

Calculated measures in MSSQL Server 2008 BDS cube

I want to define 3 calculated members. I have a cube based on 2 tables, TrackInfo and Chart Positions. Chart Positions table consists of 36 week columns, which contain given track's position on top 100 list in given week (or 0 if the song didn't make it on the list):
[Entry ID] FOREIGN KEY,
[1st Week] FLOAT,
[2nd Week] FLOAT,
and so on, until week 36.
I'd like to calculate the following measures:
1) The amount of weeks the song has been in top 10
2) The amount of weeks the song has been in top 20
3) "Popularity meter", which would be done by the formula:
1 / ((average of all nonzero positions) * (37 - (weeks featured on List)))
Can anyone help me with those?
A bit difficult without the cube definition to write some MDX but for 1) I'll take as example a similar question - number of year [Tokyo] has been in the Top 3 selling city :
select
[Measures].[Sales] on 0,
Filter(
Generate( [Time].[Year].[Year].members as s1,
TopCount( s1.currentMember * [Customers].[City].members, 3, [Measures].[Sales] )
) as s2,
IIF( s2.current(1) IS [Customers].[Geography].[City].[Tokyo] , true, false )
)
on 1
from [Sales]
This works with a demo cube available in icCube; should be the same with AS as this is quite standard MDX. I think you'll get the idea with the Generate function. Then you can create a calculated measure that will Count() the filtered set instead of putting this set on the axis (for the demo purpose).