I have a table as presented below.
I would like to calculate KPI (#Handled/#Total Offered) and present it using CREATION YEAR MONTH NUMBER on chart but when I am trying to calculate it, it changes to 100% as #handled = #total offered.
#Total Offered = DISTINCTCOUNT(TABLE[REFERENCE_NUMBER])
#Handled = CALCULATE(DISTINCTCOUNT(TABLE1[REFERENCE_NUMBER];TABLE1[IS_CASE_CLOSED])=1))
#Total Offered is presented by CREATION_YEAR_MONTH_NUMBER
#Handled is presented by CURRENT_CASE_STAGE_YEAR_MONTH_NUMBER
I would like to do it as presented below:
Do you have any idea how to solve the case?
Can you try this below 2 Measure? If your coulmn is_case_handled contain always 0 and 1 properly, these simple below measures should work for you.
total_offered = count(your_table_name[is_case_closed])
total_handled = sum((your_table_name[is_case_closed]))
Related
Looked around a long time now, and cannot find a way to conditionally format the values in a table, treemap, bar chart etc. if they are within the say, top 80% of all the values.
So let's say I have a table with sales and profit. Then I have a treemap showing the profit by city. I manage to get the percentage of total with:
% of total profit = SUM(Orders[Profit])/CALCULATE(SUM(Orders[Profit]),ALL(Orders))
..so that is no issue. But how would I go about formatting the cities that are within the top 80% of all profit? Any suggestion on approach?
Example:
Say I have the treemap below. The first four categories would fall within the top 80% of the total. Cumulatively it would be: 35%, 55%, 70% and 85%. So my need is to color only these in a specific way (and preferably any that falls outside of that range, in another color).
I take it that finding the logic to do this, likely though a measure somehow to base the formatting on, will then also be something that would be applicable to bar charts etc. (more traditional pareto).
OK, here is the solution. I will provide a traditional pareto and an adapted one according to your requirements. My data looks like this.
Create 3 measure as follows:
1
Profit Measure = SUM('Table'[Profit])
2
Pareto =
VAR amount = [Profit Measure]
VAR total = CALCULATE( [Profit Measure], REMOVEFILTERS('Table'))
VAR result = CALCULATE([Profit Measure], FILTER(ALL('Table'),[Profit Measure]>= amount))/total
RETURN result
3
Threshold =
VAR pareto = [Pareto]
VAR previousPareto = MAXX( FILTER( SUMMARIZE(ALL('Table'),'Table'[Order],'Table'[Profit],"p", [Pareto]), [p] < pareto), [Pareto])
RETURN IF( ISBLANK( previousPareto), pareto, previousPareto)
Create a table visual so you can see what is happening. In the table below, the Pareto measure is creating a cumulative percentage based on profit. If you were to use this, you can see that only A and B are cumulatively the only values actually < 80% and so they would be the only ones coloured. What you are asking for is slightly different which is what the threshold measure is showing. This outputs the previous pareto (or current if there is no previous).
In the tree map, I have created the conditional formatting as follows for standard pareto.
And as follows for the adapted pareto.
Click the fx icon under colors.
Select Rules for Format style, your measure as the field and then set up a rule (in your case, >= 0.2 for top 80%).
I´m trying to build a new measure, that show the share of "E_RATPROM"(numerical col) by "NombreCanal" and "fecha_ini_semana" defined by:
fecha_ini_semana = 'calendar'[Date]-WEEKDAY('calendar'[Date],3)
i´m working in a solution using AllExcept or AllSelected, but still cannot build it yet.
i'll appreciate any help..thanks in advance
***Update
i´ve tried the solution of Joao, but the measures dont return as expected;
***Update 2
The issue was im using an aditional column for order, so this column had to be in the ALL expression..like Joao mentioned...
To calculate your total per week, you need to ignore any filters on NombreCanal:
// Measure 1
E_RATPROM Total = SUM('mpq_comercial mqp_sales_bloques'[E_RATPROM])
// Measure 2
total_semana = CALCULATE([E_RATPROM Total], ALL('mpq_comercial mqp_sales_bloques'[NombreCanal])
// Measure 3
ratio = DIVIDE([E_RATPROM Total], [total_semana])
I have the following Table:
BaseTable
It represents processes with a certain category.
And there is also a Date Table over column TIMESTAMP.
I would like to show a Measure based on another Measure that calculates the Date-Difference until the selected Date.
So first this is how I calculate the Date-Difference:
AGE =
VAR SELECTED_DATE = CALCULATE(MAX(DATUM[Date]), ALLSELECTED(DATUM))
VAR STARTDATE_PROCESS = Calculate(MAX(Workflow[MIN_TIMESTAMP]),DATUM[Date]<=MAX(DATUM[Date]), ALL(DATUM[Date]))
RETURN
DATEDIFF(STARTDATE_PROCESS,SELECTED_DATE,DAY)
Now I want to use a Measure which depends on the result of AGE, like
NEW = IF([AGE]<=3,CALCULATE(COUNT(Workflow[PROCESS]),DATUM[Date]<=MAX(DATUM[Date]),ALL(DATUM)))
or
OLD = IF([AGE]>3,CALCULATE(COUNT(Workflow[PROCESS]),DATUM[Date]<=MAX(DATUM[Date]),ALL(DATUM)))
The Measures AGE, OLD and NEW look like that with the Base Table:
Measures
As you can see the aggregation is not working correctly:
Result_Wrong
But it should be like that
Result_Correct
Any idea how to fix that?
Thank you!
So the problem is that the subtotal is calculated at a whole different context, and because your Age measure is based on the MAX(Workflow[MIN_TIMESTAMP]) that won't take into account that there can be multiple processes.
To do what you want, you need to change the New and Old measures to perform an aggregation per process and then return the result of that. Something like this:
New_agg =
VAR tbl = ADDCOLUMNS(CALCULATETABLE(VALUES(Workflow[Process]), ALL('Date')), "age", [Age], "count_process", CALCULATE(COUNT(Workflow[Process]), ALL('Date')))
RETURN SUMX(tbl, IF([age]<=3, [count_process]))
Demo File
Let me know if below solution is working
Unfortunately I am unable to generate the dummy data that you have been using, so Created my own data for developing the solution.
Now from this data I have calculated the difference of dates and put it as Age
Now to get the count of process for the condition like yours, I have created two formulas and the result is:
Logic I followed here is, instead of creating measure I have created columns and took the sum of those columns which will give the data you need as sum of those columns.
Column for New:
New = IF((Sheet1[Age]) > 20, 1,0)
Column for Old:
Old = IF((Sheet1[Age]) < 20, 1,0)
Now place both formulas in "Values" and take sum as the aggregation.
Final result is
I’m wondering if there is a way, in a table, to calculate the percentage over a grand total.
I think this is a fairly simple issue, but I really can't wrap my head around it.
I have a table with a count, divided into different Categories:
I also have several slicers:
What I would like the table to show is the percentage of the current selection over the grand total, while keeping at least other two filters set (the Year(Anno) and another one set on the entire page).
If I select in the slicer “Range Scostamento %” a value, the table will obviously update the numbers:
The value I’m looking for is the “weight” in percentage of the filtered values over the total value.
So for example, for the first row I will have 317/14.793 = 0,0214 = 2,14% and so on.
I think my question has something to do with the SELECTEDVALUE/ALLSELECTED, maybe KEEPFILTERS, but I really don’t know how to make it work.
Thanks in advance!
Alessia
If I understand your requirement correct, you need these below measures for your purpose-
contratti = count(table_name[column_name])
grand_total =
CALCULATE(
count(table_name[column_name]),
ALL(table_name)
//-- ALL will return count of entire table
//-- you can use ALLSELECTED if you wants the
//-- grand_total for filtered data based on slicer
)
percentage = [contratti] / [grand_total]
I need to develop a report with a table that includes several dimensions and displays a sales revenue measure. Most of the times this measure throws a zero, but the user wants to visualize a blank space instead. I have searched around, but I couldn´t find anything that gives me support. So if anyone has experimented this or found a workaround I would thank you for your time.
You could use a IF condition to replace 0 with blanks. For example, if you are summarizing a field called "Sales" the following formula would work:
Measure = IF(Sum(Sales)=0,"",Sum(Sales))
Hope this helps.
Adding the additional option based on Ricardo's suggestion:
Measure = IF(Sum(Sales)=0,Blank(),Sum(Sales))
If you have a measure [Measure] and you want to replace 0 with a blank, you can do the following:
MeasureReplaceBlank =
VAR Measure = [Measure]
RETURN IF ( Measure = 0, BLANK(), Measure )
Note that since I stored the calculation of [Measure] as a variable, I don't need to call it twice (once for the condition and once for the True branch of the IF function).