Cumulative running total based on count PowerBI measure - powerbi

I'm trying to create a chart with 3 informations:
Total cases
% of total per day
cumulative % running total
The first two informations are working, but I can't make the third one work, my chart look like this
And I need it to look like this
Basically, the upper line is a cumulative sum of the lower line, the problem is that the values of the bars are just a count on my table and the lower line I made using the PowerBI function "Show as % of total"
I've tried googling but no luck with this one, tried this measure but didn't work:
Running Total MEASURE =
CALCULATE (
COUNT ( 'Primes Encerrados'[Nome Cliente] ),
FILTER (
ALL ( 'Primes Encerrados' ),
'Primes Encerrados'[Data] <= MAX ( 'Primes Encerrados'[Data] )
)
)

Use a the Quick Measure feature to get your running total formula:
Power BI will generate this formula for you:
Primes encerrados running total in Dias =
CALCULATE(
SUM('Geral'[Primes encerrados]),
FILTER(
ALLSELECTED('Geral'[Dias]),
ISONORAFTER('Geral'[Dias], MAX('Geral'[Dias]), DESC)
)
)
Add the measure to your chart and show it as % of Grand Total like you did with the first line

Related

How to Calculate measurement %sale Proportion in PowerBI

I'm newbie in PowerBI user.I create simple sale report and measurement. Like This :
My problem.In PowerBI show % calculate only Net sale and total rows but I need all % sale result like this :
Please suggest me how to solve this problem.This's my Code.
% to Sales = round(DIVIDE(
sum(DAILY_PNL_FF_TH_V2[VALUE]),
CALCULATE(sum(DAILY_PNL_FF_TH_V2[VALUE]),FILTER(ALLSELECTED(ERP_ACCOUNT[group_1]),ERP_ACCOUNT[group_1]="Net Sales")
))*100,2) &"%"
If you are trying to get the Percent of each group relative to Net Sales, then you can try something like below:
% to Sales =
VAR netSalesAmount =
CALCULATE (
SUM ( DAILY_PNL_FF_TH_V2[VALUE] ),
ERP_ACCOUNT[group_1] = "Net Sales"
)
RETURN
DIVIDE ( SUM ( DAILY_PNL_FF_TH_V2[VALUE] ), netSalesAmount )
Also, it is better to address formatting in the screen below so that the number is treated as a number rather than text. This is both for sorting and exporting the data. Also, it keeps the calculation simpler:

How to calculate average percentage in PowerBI?

Hi everyone,
I'm still new to PowerBI, right now I have a set of data in PowerBI as shown in the screenshot above. I have a Measure to calculate the % of OK:
total_student = COUNT(StudentAns[Name])
ok_% =
VAR OK_COUNT = COUNTROWS(
FILTER(
StudentAns,
StudentAns[Answer] = "OK"
)
)
RETURN (OK_COUNT/StudentAns[total_student])
I created a Matrix to show the % of OK for each month as shown in the screenshot below:
What I want to find is the average percentage for all the months. So the final output answer should be 89.05%, which is the average of 85.95%, 91.4%, 89.27% and 89.58%.
The reason I want to get the average percentage of OK across all the months is because I want to use the output as a Target Goals for KPI visualization.
Any help or advise will be greatly appreciated!
You can add one more measure to the matrix as follows:
ok_2 % =
IF(
HASONEVALUE( 'StudentAns'[Month] ),
[ok_%],
AVERAGEX(
VALUES( StudentAns[Month] ),
[ok_%]
)
)
It calculates your original measure for each month, but for the Totals it returns the average of results of your measure.
HASONEVALUE returns True if there is only one distinct value in the filtered context; VALUES - creates a list of unique values; AVERAGEX - calculates the average of a set of expressions evaluated in each row.

Is there a POWER BI or DAX code that can make a cumulative or running total of a column made by measure?

I am currently trying to make a running total for a cumulative plot of some temprature data in Power BI Desktop, but cannot get it to work.
I can see from similar posts on forums that im not the only one. My problem is that I have temperature data from a large table (20-30 degrees) and then made a measure that count the instances of each specific temperature and returns the percentage of the total instances. I want to make a running total which enables me to plot the cumulative distribution.
I have tried ranking the tempertures, and ranking by dates does not make sense. I feel like it is a pretty simple problem but i have not spend 3 days without luck.
I have added some screenshots of my data and progress so far and the code i use to calculate the percentage of the cumulative total, which is the one i want made into a running total.
Hope some of you can help me with some guidance or examples of how to tackle this issue.
Sincerly Lasse
Code
Canvas so far
Data to sum
Fault when ranking
Example of a ranking
Here you can find a good example of running Total
https://www.daxpatterns.com/cumulative-total-excel-2013/
Cumulative Quantity :=
CALCULATE (
SUM ( Transactions[Quantity] ),
FILTER (
ALL ( 'Date'[Date] ),
'Date'[Date] <= MAX ( 'Date'[Date] )
)
)
You can also use this pattern to calculate cumulative if you don't have Date column:
[CumulatedSales] =
CALCULATE (
SUM ( Products[ProductSales] ),
ALL ( Products ),
Products[ProductSales] >= EARLIER ( Products[ProductSales] )
)

Calculate percent of total considering applied filter

I would like to calculate Percentage value of total (same as inbuilt "show as -> percentage of grand total" but using DAX).
I have seen solutions
Percent of Total Windowed in Power BI DAX
and
Power BI DAX - Percent of Total Column with FILTERs
and
How to calculate Percentage out of Total value in DAX (Power BI Desktop)
but unfortunately all of them do not work for me (I get all rows filled with 100% for calculated column)
Idea is to have percetage of total but be able to apply date filter and see percent value of shown data, not entiry query
I tried as in above mentioned solutions:
Percentage =
DIVIDE(
SUM( All_Years[Price:] ),
CALCULATE(
SUM( All_Years[Price:] ),
ALLSELECTED( All_Years )
)
)
First of all I do not understand why do they take SUM in numerator. If I use just
Percentage =
DIVIDE(
All_Years[Price:],
CALCULATE(
SUM( All_Years[Price:] ),
ALLSELECTED( All_Years )
)
)
then situation looks better, I get percent value of total table in each row. But then when I apply date filter in Visual I see total 3.5% (which is correct if we consider full query and not slice that I got after applying filter)
Leaving ALLSELECTED blank also does not resolve the problem.
what am I missing?

How to calculate cumulative Total and % in DAX?

This might be very simple...
I have the below summary table in Power BI and need to build a Pareto Chart, what I'm looking for is a way to create columns "D" and "E"... Thanks in advance!
The Count from column "B" is a measure I've created in PBI based on multiple filters. I've already tried some Calculate/Sum/Filter type of expressions with no luck.
My raw data looks like Image #2... I have the measures to build the summary table with the exception of column "I" - Running % - (for which I will also need the cumulative total of events per bucket).
Unfortunately, I haven't been able to successfully apply the calculations from DAXPATTERNS.
There is a well-known pattern for cumulative calculations in the DAXPATTERNS blog.
Try this expression for Running % measure:
Running % =
CALCULATE (
SUM ( [Percentage] ),
FILTER ( ALL ( YourTable), YourTable[Bucket] <= MAX ( YourTable[Bucket] ) )
)
And try this for Cumulative count measure:
Cumulative Count =
CALCULATE (
SUM ( [Count] ),
FILTER ( ALL ( YourTable ), YourTable[Bucket] <= MAX ( YourTable[Bucket] ) )
)
Basically in each row you are summing those count or percent values that are less or equal than the bucket value in the evaluated row, which produces the cumulative total.
UPDATE: A posible solution matching your model.
Assuming your Event Count measure is defined as follows:
Event Count = COUNT(EventTable[Duration_Bucket])
You can create a cumulative count using CALCULATE function, which lets us calculate the Running % measure:
Cumulative Count =
CALCULATE (
[Event Count],
FILTER (
ALL ( EventTable ),
[Duration_Bucket] <= MAX ( EventTable[Duration_Bucket] )
)
)
Now calculate the Running % measure using:
Running % =
DIVIDE (
[Cumulative Count],
CALCULATE ( [Event Count], ALL ( EventTable ) ),
BLANK ()
)
You should get something like this in Power BI:
Table visualization
Bar chart visualization
Note my expressions use an EventTable which you should replace by the name of your table. Also note the running % line starts from 0 to 1 and there is only one Y-axis to the left.
Let me know if this helps.