Power BI 100% stacked area chart - powerbi

Hi I am wanting to get the same effect as the '100% stacked column chart' but using an area chart visual. I think the best way would be to create a measure. So far I have created a measure for the percentage
Percentage = COUNT(Locations[Latest Rating]) / CALCULATE(COUNT(Locations[Latest Rating]), ALLSELECTED(Locations))
And get the values:
However want the % out of 100. So for example "Good = 1.30%" I know the calculation should be 1.30/1.91 *100 so should be 68%. Not sure the best way to calculate this. Using a legend on the visual also.

You can use DAX and the Stacked Area Chart to produce a visual totalling 100%
With a starting point of the following data
Use DAX to calculate the daily quality rating percentage, by dividing the value by the sum of ratings across all Quality Levels (Good, Outstanding etc)
Quality Rating Percentage =
DIVIDE(
SUM(Locations[Rating]),
CALCULATE(
sum(Locations[Rating]),
ALL(Locations[Quality Level])
)
)
Add the stacked area chart to view the daily change of quality with like

Related

Problems calculating percentage of subtotals in PowerBI

I'm having problems with a line chart calculating the percentage of subtotals. What I have at the moment is as follows:
The PowerBI Data is structured similarly with a few extra columns.
I want to do a line graph where for each quarter, I have the percentage of each result for that quarter. For example, In Q4, between Business Unit A and B, I have 45 Passes, 2 Partial Passes, and 19 Fails. so of a total of 66, Q1 should show 68% pass, 3% partial pass, and 29% Fail. When I do the chart in Excel, I get the following (which is what I want to replicate in PowerBI):
In order to build this in PowerBI, I'm using a measure with the following formula:
Percentage = DIVIDE(SUM('TABLE NAME'[Number]),CALCULATE(SUM('TABLE
NAME'[NUMBER]),ALLEXCEPT('TABLE NAME'[DATE].[QUARTER])
When I use that formula, if I filter on an individual quarter, the chart values are correct, but when more than 1 quarter is displayed, the percentages are incorrect:
1 Quarter displayed:
Full Chart Displayed
The percentages between the chart in Excel and PowerBI are off when multiple quarters are displayed in PowerBI. I can't for the life of me figure out how to get the chart to be correct.
Any help would be tremendously appreciated.
Thanks!

How to create an avg measure in dax similar to the built-in chart function in Power BI?

I am trying to create an average measure that calculates/acts the same way as the Average line in the Clustered column chart does.
The avg calculated measure that I want to create should also be a straight line showing the average of the whole year and not on the monthly level as it does now. I cannot get it to ignore the month context like the built-in average line function for column chart.
This is what I have tried:
Avg. Quantity:=AVERAGEX(VALUES(Dim_Time[Year]),[Quantity])
and then place it in the Clustered column with lines chart in the line area values box. As you can see on the picture it doesn't produce the same result.
How would the dax logic need be written to replicate the same reslut as the built-in average line function ?
Best regards,
Rubrix
The core problem is the average measure you have written is being filtered by the month axis on your chart. You have to tell the measure to ignore that filter. Change cal[Month] to whatever your x-axis column is.
avg line = AVERAGEX(
ADDCOLUMNS(
SUMMARIZE(
ALLSELECTED(cal[Month]),cal[Month]),
"#qty",CALCULATE([Quantity])),
[#qty])

Hi, Is there a way to build a power BI bar chart using multiple heirarchies and avoid calculating averages of averages when drilling up?

I have a dataset with columns Country, State, City, Sales. I wanted to build a drill down bar chart to drill from country to State and then City, showing the average sales. My problem is that I can't find a workaround to avoid power bi calculating the average as the average of the inmediate lower heirarchy. Since I have States with much more cities than others, when I get to category Countries, the averages are wrong, because Two States with different amount of cities are weigthed the same way when summarizing to the upper level.
Is there any way to define the granularity level on which averages should be calculated or any other workaround.
Example
example dataset
For country A, I want to show the average as 16.
Currently is doing the average between States X and Y, whose averages are 17.2 and 13, giving 15.1 as a result.
Any help on how to solve this problem will be preciated. Thanks.
avgMeasure:= CALCULATE(AVERAGE(tbl[sales]),ALLEXCEPT(tbl,tbl[country]))

Can we do conditional formatting in Power BI using DAX?

I have a KPI which I need to conditional format based on a dynamic condition.
Example:
KPI : A
if A > Average of A in that cluster(A column present in the table) then the cell should be RED
if A lies between some values then the cell should be AMBER
if A lies below some value then the cell should be GREEN
I was doing conditional formatting by RULES prior to this but I cant seem to find an option there which can dynamically calculate the Average cluster total or Average country total and format the cells with colours.
Even if I make this DAX expression how do I put it in the table?
Also, is it even possible by DAX?

Get correct value in column sub total

In Power BI I am working with a matrix that shows a daily percentage.
When I add a column subtotal this sub total is summing up all the percentages for the selected days.
What I would like is that the Column sub total is showing the average percentage over the selected days.
Picture of the matrix
Thanks a lot for looking at my issue
Depends on how you calculate the percentage itself and on what granularity it exists in your data model, but you might want to play around with the ISFILTERED formula. Not sure what the name of the dimension ranging between 1 and 6 is in your graph, but let's call it day number. You can then do something like:
IF(ISFILTERED(day number), SUM(daily percentage), AVERAGE(daily percentage))
This checks if the daily percentage is filtered by the day number in the visual (matrix) or not. If it is, then it just takes the sum of the percentage (which is the percentage itself for any given day), otherwise it'll calculate the average percentage.