Is there a way of grouping Power BI pie chart slices? - pie-chart

I have a large excel report with information on IT incidents and I need to create a pie chart in Power BI showing the number of incidents by priority (P1 to P5). But I need to group the priorities into two groups: P1 - P3 and P4 - P5.
I have the graph made already, but I can't find a way of grouping the slices.
Any ideas?

Use DAX to define an extra column as follows:
PriorityGroup = IF(OR(Incidents[Priority]="P4";Incidents[Priority]="P5");"P4-5";"P1-3")
And use this column in your pie chart.

Related

Power BI - Timeseries compare two different start dates

I want to compare how different campaigns are progressing based on number of days into the campaign rather than by date (see day1, day2, etc... on the x-axis below).
Here is my DAX code, but I can't get it to work. Any help would be much appreciated...
**Normalised Campaign Metrics =
VAR DateReached = CALCULATE(MIN(Days[Day]),db[PAYMENT_DATE]<> BLANK(), KEEPFILTERS(db[PRODUCT_CODE SWITCH]))
VAR MaxDate = CALCULATE(MAX(db[PAYMENT_DATE]),KEEPFILTERS(db[PRODUCT_CODE SWITCH]))
VAR DayNo = SELECTEDVALUE(Days[Day])
RETURN CALCULATE(count(db[PAYMENT_DATE]),
FILTER(ALL(db[PAYMENT_DATE]),
DateReached+DayNo && DateReached+DayNo<=MaxDate))**
Many thanks!
enter image description here
I would recommend solving this through manipulating your actual data rather than a complex DAX measure. If you are familiar with star schema modelling, I would solve this problem by adding a new column to your fact table that calculates how many days from the start date the payment occurred and then connect this column to a new "Days Passed" dimension that is simply a list of numbers from 1 to however many days you need. Then, you can use this new dimension as the source data for your x axis and use a standard payment amount measure for your y axis.
I recommend to create a dimension table as the relative basis to comparison with inactive relationship. Here is a video about it:
https://youtu.be/knXFVf2ipro

Chart showing amount of numbers in dataset in Google Sheets

I have a set of 500 numbers (range A1:T25) from 1-200 that I need to put in a pie chart showing the popularity of each number from 1-200. When I try to select all of the cells and put them in a pie chart, I can see multiple slices for each number. I even tried putting the cells into a single column.
=QUERY(QUERY(ARRAYFORMULA(TRANSPOSE(SPLIT(JOIN(" ",
QUERY(A1:T25, , 10000)), " "))),
"select Col1,count(Col1) group by Col1 label count(Col1)''"),
"order by Col2 desc")
I hope your data is not uniformly distributed—pie charts with 200 slices can be hideous!
If I'm understanding your goal correctly, you don't actually want a chart of those 500 numbers, you want a chart of how often each value appears in that set. Generate a report of that data in pairs, and chart that.
For example in a cell with 200 empty cells below it, say A30 or V1, enter:
=ARRAYFORMULA(ROW(1:200))
These are your possible values, 1 to 200.
Then next to it in say, B30 or W1, enter:
=ARRAYFORMULA(COUNTIF($A$1:$T$25, "="&ROW(1:200)))
These are individual counts of how often each A column number appears in A1:T25.
Now that your values and their 'popularity' counted out, create your pie chart from that.

Creating a "stacked" Gantt chart in Tableau?

I'm working with a dataset that describes contract durations with a list of companies. Obviously all contracts have a start date and a (minimum) duration. Some contracts however, are subject to possible prolongation. Here's a data example:
Company contractStart minDuration firstProlong secProlong
Company x 27-11-2011 27-11-2014 27-11-2015 27-11-2016
Company y 29-11-2014 29-11-2015
Company z 01-04-2011 01-12-2011 01-12-2015 01-12-2017
I want to visualize them in a Gantt'ish type diagram that has duration along the x-axis, and shows the respective contract lengths with the possible prolongations as a sort of stacked bar chart. Along with that I want something to mark the current date. I've managed to do this in Excel. See picture:
.
I would however really like to be able to the same thing in Tableau, and I really can't figure out how to. I've been working with two different approaches so far:
1st approach
Here I drag the Company to the Rows shelf, and the contractStart date to the Columns shelf. I then create a calculated field that calculates (with DATEDIFF) the difference in days between the contract start and the minimum duration. I can drag that to the Size shelf, set the mark type to Gantt bar, and get something like this:
I can then go on to calculate the date difference between the minimum duration and the 1st prolongation and the same for the 1st and 2nd duration. The problem here is that I can't add these calculated fields to the Size shelf as it can only hold one at a time.
2nd approach
Here i reorganize my data like this:
Company Type startDate endDate
Company x minDuration 27-11-2011 27-11-2014
Company x firstProlong 27-11-2014 27-11-2015
Company x secProlong 27-11-2015 27-11-2016
Company y minDuration 29-11-2014 29-11-2015
Company y firstProlong
Company y secProlong
Company z minDuration 01-04-2011 01-12-2011
Company z firstProlong 01-12-2011 01-12-2015
Company z secProlong 01-12-2015 01-12-2015
I then create a calculated field to find the difference in days between startDate and endDate. I drag that to the Columns shelf and drag Company to the Rows shelf. I then drag Type to the Color shelf, set the mark type to Bar, and get something like this:
The problem here is that I need dates along the x-axis not integers. Also I need to be able to sort the chart like my initial Excel example. I.e. I want to sort on the longest possible duration of a contract (ascending). Also having to reorganize all my data seems a bit tidious.
Here's the spreadsheet and the tableau file I've been working with. Am I overlooking something really simple?
Your approach 2 is close. instead of sum(datediff) on the columns, place StartDate as continuous. Then place sum(datediff) on size. You can now sort Company ascending on sum(datediff). Sometimes, reorganizing data is necessary.

slice chart bar into two in cognos

I need assistance on Chart in Series (primary axis), I need to create a condition that will slice the chart bar into two separate bars based on the measure condition
It can be a filter or tuple or calculation. I will have to create two bars: one when the measure is negative and the other when the measure is positive ('Overdue' and 'Pending')
The chart is based on Cube.
Dimension: Action (Source: 'Action Code', Label: 'Action Desc')
The measure: 'Days Between' which is the number of days between the Action date and current date.
Example: for the Medical Action, I need to separate it in 'Overdue' and 'Pending'
Your question is rather generic so the answer will be the same. Birt data sets enables both filtering and adding computed columns. You need to specify only what you want to filer and how you want to calculate it.
Then create simple chart displaying filtered/calculated data.

Plotting a pie chart on tableau

I am new to Tableau and I am trying to create a pie chart on tableau using the following sample data. Could some one help me out.
I have added Sum and date to the measures side and t1 , t2 to the dimensions side. But I end not getting any pie chart as expected.I wanted to just visualize how the sum of 100 can be shown as percentages of t1 and t2 on the pie chart
Actually it is pretty simple. you will have to rearrange your data as below.
Date Section Count
1/1/2012 t1 50
1/1/2012 t2 50
2/1/2012 t1 45
2/1/2012 t2 55
and then refer to the instructions.