Dynamic Spotfire KPI Formula Based on Selected Master KPI - visualization

I have a master KPI chart that has a detail KPI chart listening to it. The master KPI chart can have two measures (for simplicity): Eng Displ and Cylinders. The detail KPI chart then responds when the Eng Displ KPI is selected to show Cylinders broken down by business area:
I now want the detail KPI chart to break down Cylinders if it is selected without creating another details visualization (I want it all in the same visualization).
tl;dr I want a details visualization to change formulas depending on which part of a master visualization is selected.

There are a few steps to doing this.
Set up a document property. We will assign a value to this in the next step through the use of a Python script later.
Set up a python script for each master KPI (in my case, two). This script will look similar to this (this will also live in docuent properties - Scripts):
Document.Properties['KPIMeasure'] = '(Avg([Eng Displ]). Change the script formula depending on the KPI you are creating it for, but have it assign to the same Document Property you created earlier.
Create an action on each master KPI that calls the appropriate script (the script with the correct formula). When the master KPI is clicked, the script will fire, and set the formula for the detail KPI accordingly (in the step below).
In the detail KPI, create a custom expression as ${KPIMeasure}. This will be set when a master KPI is selected to whatever formula that master KPI has (whatever is in the Python script).
Of course, you can edit the python script to also change the name of the detail KPI dynamically as well. The one downside of this is column names, if changed in the table, will not update automatically in the Python script because it is seen as just a string.

Related

statistics on individual path agents

I am simulating a medical stay and would like to calculate for each patient generated the cost of their stay. I have created a parameter that is updated each time the patient receives care. However, to plot it, I created a histogram data with a cyclic event that updates the values every hour with the following code:
this.CostperPatient.reset();
for (Patient patients: this.patients)
{
this.CostperPatient.add(patients.cost);
}
However, the chart it produces does not give an indication of individual patients, it makes a percentage.
Is there any way to output a graph with the cost for each individual patient?
Thank U
Miriana
While I am not sure what you are trying to show, it seems that in your case, you shouldn't be using a histogram, instead you should probably use a bar chart where each bar is for a patient. To do so, drag to your model in the main environment a bar chart element and call it chart. To dynamically add bars to this element, you need to use something called "data items". For now, remove all data items from the chart by clicking on the X in the properties.
Then, go to the Agent window, so your patients' agent window. Add a variable. Set it as follows:
Then, in the agent's properties, in the on startup field write the following:
Finally, add a cyclic event in the agent's window with the following code:
patientCost.setValue(cost);
Where cost in the above, refers to your initial variable called cost in the question. That should do it.

Tableau subtotal in graph

I am trying to make a graph/chart of showing a measure category-wise. The categories are further subdivided into sub-categories and these sub-category has also been added in the view.
What I am trying to achieve is to include category wise measure sub-total in the view but as a label only. If I am adding sub-totals from analysis pane, another bar is added which I do not want. I only want that these sub-total values be displayed as a label under each category.
How should I proceed?
For this purpose sample superstore data on tableau may be considered.
I have done some workaround to show it like this.
step-1 added a desired 'sub-total' field like this (Sample -superstore data in tableau)
{Fixed [Category]: SUM([Sales])}
Created a view thereafter like this, which in my opinion should serve your purpose

Tableau - KPI (Forms) using different variables

Im trying to perform a KPI on Tableau based on the rank of certain variables such as sales and profit as the excel example below
KPI = If the country position (using rank formula on Tableau) is on TOP 3 = GREEN; TOP 5 = YELOW; OTHER = RED. As the second table shows
On Tableau, I would have to create 2 calculated field KPI_SALES & KPI_PROFIT following the logic above
The ideia is to use the forms with the 2 calculated fields created above, however, the problem it that Tableau only allows to use one variable on forms which is my problem, i will have to use 2 variables on this example
There is any other way to accomplish it?
Yes, you can do this. Go to each sheet and click on the Label Card in the Marks Shelf. Then click the box that says "Allow labels to overlap other marks". See picture.
I have solved the problem by creating fake columns such as sum(0)
so each card would allowed by the chose different variables to put on marks as the picture below shows

How to create Line chart from birt chat plugin in eclipse

I am using eclipse brit plugin to generate a line chart. Basically i want to create a report to present a mobile battery usage in given time range. Here is sample data where observationtime is dynamic based on user selected range:
I want to draw a line chart of per device but unable to find any configuration to draw different charts per device on same report page. Can someone help me on this ?
------------------------Update configuration and result-----------------
------------ after using list -----------
I the "Select Data" tab of your chart, select the time for the Category (X) Axis, The battery usage for the Value (Y) Axis an the device name for "Optional Y Series Grouping" (on the right side of the chart).
I found a solution basically we need to add a table and then add grouping inside tablet on desired field and then in footer need to add a chart and it should get the values from container rather than directly from Data set.

How to pass values from datasets back to main report?

Problem:
I have composite JRXML report. Composite report contains many charts. Each chart is assigned to some dataset. I need to pass the variables/parameters values back to main report from datasets?
Tried:
I tried scriptlets, customizers but they are all scoped to the dataset to which they are assigned and cannot see or change the parameters of the main report.
Global scriptlets do not have knowledge about dataset parameters(to be precise they do not know their values and they can't assign their values, they only can find out their description and names via usage of JASPER_REPORT parameter which has mainly lookup functionallity).
This poses a fundamental problem for me as I can't aggregate values in one place as I can't extract them from each individual dataset.
Context problem:
The reason I need to do this because Jasper reports design is flawed for one fundamental requirement: "consistent colours" across all the charts in the composite report. So if you have "China" in Pie Chart and it has colour GREEN and you also have Bar Chart having different query but returning some values which exist in Pie Chart - you'd want the China to have GREEN colour in Bar Chart too.
Approach to context problem:
For this task you need to exctract all the field values from each dataset and save them in main report parameter. You then have to assign each value to some color value and check aggregate main report parameter inside customizers whether current value has a color assigned. This is at least my plan. For this task I need to be able to get back data from datasets generated by their local queries. But I am limited by the scope of datasets as they work only on input data not output data.