How to write Maxx dax function to get maximum value per each group - powerbi

I am trying to get Max of fee rate for each stream. I want to get the result as desired max fee highligted in yellow as shown in the table below.
I tried this dax calculation:
Desired max fee = MAXX(VALUES('Session Budget Tracker'[Stream]),CALCULATE(MAX('Session Budget Tracker'[Session Fee ($)]),ALLEXCEPT('Session Budget Tracker','Session Budget Tracker'[Stream])))
Can anyone help me to get the correct values please?

You can use calculate as shown below. it is taking the max based on each stream.
Desired max fee =
var progStream = 'Session Budget Tracker'[Stream])
return CALCULATE(MAX('Session Budget Tracker'[Session Fee ($)]), FILTER('Session Budget Tracker','Session Budget Tracker'[Stream] = progStream))

Related

How to have the table total the sum of my measure which has an IF condition

I'm creating a table that automatically calculates the bonus for each salesperson based off their sales figures. I'm struggling with the measure
Whale Accounts =
IF('Oct-Dec Refresh 1.5.23'[YearOverYear Variance] >
800000 && 'Oct-Dec Refresh 1.5.23'[Percentage Difference] >= 1.1, 2500, 0)
Any account that sold over $800,000 and had a sales growth increase of 10%, receives $2500 in bonuses. I created the measure and it shows $2,500 for each account that meets this criteria, but the table doesn't sum it, how can I get the table to sum the total?
Also, both YearOverYear Variance and Percentage Difference are measures. I have attached an image for clarification
I tried creating custom columns, using SUM, CALCULATE but I haven't been able to figure it out.
You need a summing iterator over your accounts for this. Something along the lines of:
Bonus =
SUMX (
VALUES ( 'Table'[Master Bill To] ) ,
[Whale Accounts]
)
Where the account column is the one you are using in the visualization!

Average doesn't calculate correctly in PowerBI

It wont be possible to share my data.
I've a lot of purchasing information with purchasing day, supplier, delivery value and quantity.
When I try to summarize it to get an average price per unit (Value / quantity), my calculations goes crazy.
Sometime delivered quantity for all deliveries haven't been registered, that results in "NaN". So i've been using a powerQuery to avoid that.
Formula: = if [Delivered Quantity] = 0 then 0 else [Delivered Value]/[Delivered Quantity]
Below is a picture of my problem, as you can see the "price per unit" is WAY to big.
Even if I delete the above formula and only use [Delivered Value]/[Delivered Quantity] and hide inifinity/NaN in filter, it still get some errors.
tried using an DAX formula:
avg price =
sum('Sum Tbl'[Delivered Value]) / sum('Sum Tbl'[Delivered Quantity])
and it worked.

Sum of a column but give the average of the sum for every applied filter?

I give here a sample data:
As you see we have a fact table for monthly expenses, and daily occupancy FT with row for every day for each residence. The residents vary but most of them are permanent. I think this is not
The goal is to find the expense for each resident per day.
The calculation for that is:
PRPD expense = SUM ( actual_amount) / SUM ( number_of_residents )
I put that PRPD expense in a card on the report page and I have filters for Year, Month and Residence Name.
If I select both residences for January the calculation is as follows:
(3000+2500) / (30+31+31) = **59.78**
In reality we have:
For Residence A:
3000 / (30+31) = 49.18
For Residence B:
2500 / 31 = 80.65
The average for both residences:
(49.18 + 80.65) = **64.92**
And the average is what we need. How do I accomplish this?
Thank you in advance.

Calculate monthly Avg of daily percentage values

We have a report in Compliance% which is calculated every day. I have a requirement to calculate the Monthly Average of these daily Compliance% values.
PowerBI currently gives incorrect total value in a table format, I have attached the sample file. It is giving 56.90 in the grand total whereas I want to calculate sum(Compliance%)/count(day or month).
Could someone please help.
[
I think you need to introduce a new measure:
mDay =
IF(
HASONEFILTER(Table1[Compliance %]),
SUM(Table1[Day]),
FORMAT(
SUMX(Table1, Table1[Compliance %]) / COUNT(Table1[Day]),
"0.00%")
)
Here's the result for the month of February:
Here's another one if you also include a few values from March:
As you can see the measure responds to your table filters.
I hope it helps.

How can I measure Number of Items with over X amount of sales?

I have a Power BI database set up as follows:
Sales[Date] is the date in which the sale took place. Sales[ProductID] is the SKU, while Sales[Units] is the number of units sold per SKU. I have also added a measure to calculate the total # of units sold. I am trying to set up a distinct count of SKUs where more than 500 SKUs were sold. I am using the following formula:
SKUsWith500Sales = CALCULATE(DISTINCTCOUNT(Sales[ProductID]),FILTER(Sales,[TotalUnits]>=500))
The output is either blank or inaccurate.
Thank you!