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.
Related
I'm having a hard time to calculate the running / cumulative total of average values...
My idea is to emulate a sales campaign for a product that never had one, using the average by day of all the products from an specific brand; problem is the code I made is only repeating the numbers from the average, it's not summing them up:
This is how it's now:
This is how it should be:
I managed to filter the values I want to calculate the average for, and that's for an specific brand (this is not going to be replicated to all products, and in the end I want to merge this in another calculated column which will calculate the goal for all the products (including the exception, which are the ones that never had a sales campaign before).
here's the code for the average:
AllPlutoProductsAverage = MAXX(FILTER('f_Leads(teste2)', [percentage] = EARLIER(d_CT_Leads_RT[percentage]) && 'f_Leads(teste2)'[group_name]="Pluto"), 'f_Leads(teste2)'[registers_per_day] )
And here's the code for the cumulative/running total column:
VAR _NoCampaign_RT =
CALCULATE(
MAX( 'd_CT_Leads_RT'[AllPlutoProductsAverage ] ) ,
FILTER( 'f_Leads(teste2)' ,
AND( 'f_Leads(teste2)'[group_name] = d_CT_Leads_RT[group_name] ,
'f_Leads(teste2)'[course] = d_CT_Leads_RT[course]
) &&'f_Leads(teste2)'[course_closed_percentage] = d_CT_Leads_RT[percentage]
)
)
Any ideas on how I fix that...?
Thanks in advance!! :))
I tried:
quick measure for running totals, didn't work
custom code for running totals, still repeated the values
creating a separate measure for average and then mentioned it on the column's running total code, same result
tried building up a running total code by adding the average calculation into it as a variable, didn't work either
tried exporting the calculation to a measure, didn't work either
And by 'didn't work' I mean the column No_PreviousCampaign still shows the repeated values from AllPlutoProductsAverage
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!
I am trying to use a measure to find the total impact of a price change.
Currently, I have a table with the date, region, product quantity, and revenue.
I have measures that return YTD and PY YTD for both revenue and product quantity.
AvePriceYTD = Rev YTD/ Q YTD and AvePricePYYTD = RevPYYTD/Q_PYYTD
My final measure is PE = (AvePriceYTD-AvePricePYYTD)*Q_PY
When totaling the AvePriceYTD-AvePricePYYTD is correct but when multiplying Q_PY it gives a different result to the sum of the individual PE for each region.
I know that this involves the HasOneFilter to choose the total but not sure how to evaluate each region individually and then total. It is not possible to evaluate each row as this is monthly data and there are multiple rows per region.
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
This link explains the answer, I initially didn't realize that the _table and _value were actually mean to be typed and not replaced with your own text.
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.
I'm having an issue that i can't seem to solve on my own:
I have a model that has two tables.
Fruit_data_Table
Date
Fruit_id
Fruit_category
Fruit_scheduled_picking_time
Fruit_real_picking_time
Fruit_picked_within_1min = 1 or 0
Fruit_picked_within_5min = 1 or 0
etc etc
On every given day i have 700 different fruit entries on my fruit_data_table.
I created a Calendar_Table using a classic :
Calendar_Table= CALENDAR(MIN(Fruit_data_Table[Date]);MAX(Fruit_data_Table[Date]))
And then i needed combined averaged values for any given day, including rolling averages, so inside my Calendar_Table i added some calculated columns for every dates such as :
Fruit_on_time_1_min_pick=
VAR this_date = Calendar_Table[Date]
RETURN CALCULATE(
SUM(Fruit_data_Table[Fruit_picked_within_1min ])/COUNT(Fruit_data_Table[Fruit_picked_within_1min ]);Fruit_data_Table[Date] = this_date)
Or a rolling average :
Fruit_on_time_1_min_pick_7day_average=
VAR this_date = Calendar_Table[Date]
RETURN CALCULATE(
SUM(Fruit_data_Table[Fruit_on_time_1_min_pick])/COUNT(Fruit_data_Table[Fruit_on_time_1_min_pick]);
DATESBETWEEN(Calendar_Table[Date];DATEADD(LASTDATE(Calendar_Table[Date]);-6;DAY);LASTDATE(Calendar_Table[Date])))
Which mean i ahve something like
Calendar_Table
Date
Fruit_on_time_1_min_pick (%)
Fruit_on_time_1_min_pick_7day_average (%)
etc etc
This all seems to work pretty well and i have my daily rate of fruit pciked on time and rolling averages.
The problem is that then i can't use my slicer to sort by fruit_category, or by time_of_day for example... any idea how i can get back to those slicers ?
(The PowerBi rolling average function don't seem to work at all for me, even though my Calendar_Table is a PowerBi generated Date Table...)
Thank you very much !
PS: real code is about train numbers is a major french train station... not really about fruits :)