Power BI: Calculate the Maximum of an Average Value - powerbi

I have a table that depicts the turnover and uptime of a group of assets for a particular date range. It has the following columns:
Date, Asset_ID, Turnover, Uptime, Turnover/Uptime
What I have calculated in addition is the average Turnover/Uptime for the entire group of assets for a given date range. Every asset's Turnover/Uptime is then compared to that average to see how it performs relative to other assets.
In addition I would like to calculate the following: The highest (thus the Maximum) average Turnover/Uptime of any single asset for the same period. With the goal of expressing each asset's turnover/uptime as a percentage of this maximum value.
I have not succeeded in this. Any ideas?

The question is not clear but if you are asking: how can I calculate the maximum of several averages, then here is my suggestion.
The pseudo-algorithm is the following:
Calculate the KPI at the level of granularity you need
Identify the maximum value
The KPI could be
MAX(AVERAGEX(ALL('Table'[Asset Key]), 'Table'[Turnover / Uptime]))

Related

How to add new row to table on PowerBI

So basically, I am trying to edit a dashboard that someone who left my company made. I want to add a row at the end of the upper table in Image 1 that says Gross Profit, which will of course just be Turnover - Cost of Sales.
In fact, a measure with that calculation called "Gross Profit" is already in the fields (see Image 4). When this is checked along with other measures and put in "Values", it produces the lower table (see Image 2). This is what I would like to be seen in the upper table.
Of course, the problem with that is that in the upper table (Image 1), each row is a Group, made up of Lines (See Image 3), and in order to add "Gross Profit" I'd have to create a Calculated Line that calculates Turnover - Sales for every single date. That would take far too much time.
When I do check the Gross Profit measure when on the upper table, it just looks like Image 3, with Gross Profit added as a column total after every Amount.
Is there any easy fix where I can add Gross Profit as a row in the upper table, like how it is in the lower table (Image 2)?
Thanks for reading.

How can you not sum the averages?

So the main problem is that I would like to show the average numbers per Week numbers. But I don't know why but it sums up all the averages, and not just average the averages.
My current DAX formula:
Average =
AVERAGEX(
FILTER('Code',Code[Code_name] = "Failure"),
CALCULATE([Time])
)
Where Time is another Measure.
you can see that calculating the average by ID works, but if you collapse the matrix it shows weird numbers per week number.
Any advice?
Consider changing the "Show value as" in the visualization.
By default it is sum, try average of your measure.

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]))

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.

Weighted Average Cost across 2 tables power BI

I am looking to calculate a weighted average cost of products that are on 2 separate tables within power BI. One for demand and one for supply. The common factor between the two tables is 'Datetime' that is every half hour period for the next few years. E.g.
Table A (Demand)
Total Value, Total Volume, datetime (half hourly)
Table B (supply)
Total Value, Total Volume, datetime (half hourly)
Within both of these tables, price can be calculated my just doing Value/Volume.
For the weighted average price within one table I have used a measure:
Weighted average price =
sumx(table A, Table A[price] * Table A[Volume]) / sum(table A[Volume])
This seems to give me the correct weighted average price within each table. However if I try and calculate crystalized profit and loss which is the profit and loss between demand and supply (P(d)-P(s))*(supply volume) this doesn't work. I presume this is because sumx isn't smart enough to calculate the P/L for each half hour everyday and then add all these half hour P/L up to get total P/L.