How to get additional records based on dates - spotfire

In my bar chart visualization, my value axis is:
UniqueCount([Case ID]) - UniqueCount([Case ID]) over (Previous([Axis.X]))
My category axis is:
BinByDateTime([Date],"Year.Month",1)
Is there any way to create a detailed visualization to show the additional [case id] for each month?

Related

Need to find the average of all values in pivot table

I have a data table that is pulling all successful contacts by case manager over a period of time. We've created a pivot table of the data that groups by case manager for the rows and by month of the contact for the columns. It counts the appointment IDs to get counts per case manager per month.
My manager wants this data displayed in a chart to easily visualize the data. The part I can't get is she wants the average contacts per month over all the case managers and all the months to be displayed on the chart. Essentially, she wants the average of all the values in the pivot table.
I've played around with power pivot and the DAX functions averagex() and summarize() to get averages in the total row per column, but the ultimate grand total is still the average of the totals.
How can I get the average of all the fields by itself?
Here is the sample pivot table with the totals per case manager per month
Here are the totals using averagex(summarize()) to get counts for the values and average for the totals.
AVERAGEX ( SUMMARIZE ( Table1, [Caseload], "x", COUNTA ( [Client ID] ) ), [x] )
However, the real average I want to see is 34 (all the values averaged together
You need to summarize by month as well to be able to average the way you want.
avg_count =
AVERAGEX (
SUMMARIZE (
Table1,
Table1[Caseload], --Assuming this is what you have on the rows
Table1[Month], --Assuming this is what you have on the columns
"x", COUNTA ( Table1[Client ID] )
),
[x]
)

How to aggregate data in table by month in spotfire

So my original table is like this:
And I want to compress the table which only shows that factoryID and the month, and the max output like this:
How do I do this with spotfire in table visualization?
To go from the top table to the bottom table:
Do these steps:
Create a new calculated column off of your date for mmm-yy: Concatenate(Month([Date]),"-",right(String(Year([Date])),2))
Add a pivot transformation with the following parameters:
I created it as a new table but you do not have to.
Create two caculated columns.
c_month, c_max
for c_month, use the expression: Concatenate(Month([date]),"-",Year([date]))
for c_max, use the expression: Max([max]) OVER ([factory id])
Add third column called c_rank
expression:
If(Rank(RowId(),"asc",[factory id])=Min(Rank(RowId(),"asc",[factory id])),True)
//this will create a new calculated column which will give true only for every unique value of factory id.
Add a data table to your visualization
Add data limiter
Right click and under data --> Limit Data using expression, enter [c_rank] = true
Create Table with limted columns
Only add factory id, c_month and c_max to your column list.

Calculate median of aggregated values for a category using pivot table

I have hourly data about sales $ of certain categories (Fruits, snacks etc). I'd like to display the median of daily sales values over a month or an year using the hourly data in the table. So, for each category it needs to sum the hourly values and create a daily value first and then calculate the median
regular pivot does not provide median function. I am familiar with Power pivots but have not used Measures. i tried to create a measure using medianX function, but could not make it work
First, you will need to add a Calendar table to your data model:
Calendar Table Explained
The Calendar table must have fields you want to group your sales by, such as "Year-Month" and "Year-Quarter".
Then, connect the Calendar table to your Sales table via date fields, to get a structure like this:
With this data model in place, create 2 measures ( I will assume your sales table is called "Sales", and calendar table is called "Date"):
Measure 1:
Total Sale = SUM(Sales[Amount])
It will simply calculate sum of sale amounts.
Measure 2:
Median Monthly Sale = MEDIANX( VALUES(Date[Year-Month]), [Total Sale])
This measure will first sum up sales by Year-Month, and then calculate the median of the sums.
To get median sales by a different period, just replace Year-Month with the desired grouping level, for example:
Median Yearly Sale = MEDIANX( VALUES(Date[Year]), [Total Sale])
Ali,
When you create your measure you will want to use the MEDIAN funciton not MEDIANX
The MedianX would be if you were trying to calculate the median value for a column in your table that did not already exist.
For Example, lets say we have Table1 which has two columns Net Revenue and Net Expense. And the following 3 data points exist for each row in the column.
Net Revenue:
Jan-2019 100
Feb-2019 300
Mar-2019 300
Net Expense:
Jan-2019 50
Feb-2019 100
Mar-2019 50
Since we do not have a Net Profit column in the table we could use MEDIANX to specify the table we would like to use then write our expression for the column that doensn't exist. In the example above it would go =MEDIANX(Table1, [Net Revenue] - [Net Expense]. This would create a median measure for NetProfit even though the column itself doesn't exist in our table.
In your case, since you are aggregating a column that already exists you can just stick with =MEDIAN.
If you need more clarification let me know!
Best,
Brett

Spotfire - Calculate Difference between two values in a graph create by date

I am shwoing a data of pressure in a graph by date which can selected from the filter ( days, months, years) 
I would like to calculate the difference between the twos extremum data in the plot  [ last Value-  first Value] ( when user change a filter i show the new calculation as the graph will change )
here my custome expression but i not working properly ( Date is X axis values ) Level Pressure Y axis :
Abs(if([Property Name]="LevelPressure",[Average Reading])) - sum(if([Property Name]="LevelPressure",[Average Reading])) over (PreviousPeriod([Date]))

Pivot table with multiple items per transaction

I am trying to create a pivot table and pivot chart in excel 2016 based off of cattle auction data. Data for each auction includes: Head of Cattle, total weight, avg weight, price per lb, and price a head. I am trying to show the avg price per head of particular weights. The trouble is when one transaction is for 30 head # $800 and the next is for 1 # $700 it shows average price of $750. But I want to show the average weight of the 31 cattle at $796 not the average of the transactions # $750. Any ideas?
From what you've laid out in your question, it sounds like you should do some calculations in your data before you pivot it. Basically, make a new column that is [transaction] * [the head of cattle], so in this case the new column values are 24000 and 700, respectively.
From there, you can insert a pivot table and use a custom calculation. While in the pivot table click on 'Options' and then click on "Fields, Items, & Sets". Then set the calculation in the formula bar to your new field divided by head of cattle.

Resources