I'd like to show the average unit cost in each year for a series of items I'm purchasing. I'll be purchasing 13 items over 10 years. In some years, I purchase multiple items, in others, I purchase only one.
My Measure is Sum(Cost)/DistinctCount(Items). In all cases, this results in a count of 13 items, rather than the number of items in a given year. For reference, I'm using this in a line chart, where years are along the x-axis, so I (wrongly) assumed that the Year context would apply. Any suggestions?
For example, in one year, I'm purchasing 5 items for $350 dollars, which should result in an average unit cost of $70, but is instead returning $26.92, which is 350/13.
If the year context doesn't apply, then it sounds like an issue with your data model. Have a look at whether there's a relationship from your Date table to your Fact table (the one with the item counts).
Related
I am trying to put together a report in which I have 2 card visuals (for two separate years) that show the total number of stores that sell at least an average N of products each month.
The measure I tried making in Dax finds average sold by year, but would I also need to take store into account there within the measure?
Either way the Card visual wont let me filter by my measure
Here is a very simplified version of the data: Sample Dummy table
Essentially wanting to show one card that shows the number of stores that are averaging at least 2 sales per month so far this year. And one that shows the same metric to this point in the prior year
I also have my table linked to a calendar table
We run a hotel business. The structure of my fact table is arranged as a P&L report. Every month has a row for specific line items.
There's Month/QTD/YTD/L12M period slicers.
I've added columns for the total number of rooms sold and travelers per month in order to use them as references for writing Measures. This number stays constant throughout the month.
I want to build unit analytics into the dashboard. For example, the cost of linens per traveler per month. If I choose QTD, I want to add up the linen cost this quarter and divide by # of travelers this quarter.
To do this, I first created a Travelers Measure to start. The issue I'm running into is how to make it react to the period slicers.
If I try to use:
Travelers = SUM it adds up all the travelers or rooms sold even if it's within the same month (ie. in January - if I have 10 line items for the report and there were 10 total travelers, then it would show 100 travelers)
Travelers = MIN displays the correct number based on the selected month slicer, but fails to SUM the travelers based on the period slicer chosen. (eg. if I had 30 travelers QTD, it would still only show the number from the chosen month).
I'm no longer sure whether this is a DAX issue or if I should arrange my data differently.
Thank you!
Link: https://www.dropbox.com/s/5wl4dc5f560cswv/TestReport.pbix?dl=0
EDIT: I added additional information and context in a new post here.
I am trying to figure out what life after pandemic looks like for my firm.
We are currently operating at about 20% capacity for shipping orders. It is expected that those orders will return after the pandemic subsides.
I have a measure that calculates 80% of our backlogged orders. How to add it to the remaining dates of the year in my model? I assume I need to somehow strip the date context and then parse the total out amongst the remaining days...but I don't have the slightest idea how to begin doing that.
I'd like my total to be spread evenly over the next 4 months. Spearing it evenly by an upper limit works, too.
Any ideas?
I would like to create a calculated column or measure that shows the time elapsed in any given month. Preferably as a percentage.
I need to be able to compare productivity (rolling total) over a month's period between different months.So creating a percentage of time passed in a month would put every month on a level playing field.
Is there a way to do this?
Or is there a better way to compare productivity between 2 months on a rolling basis?
EDIT
I am graphing sales on a cumulative basis. Here is a picture of my graph to demonstrate.[][
Ideally I would like to be able to graph another person's sales on the same graph for a different month to compare.
The problem is each month is different and I don't think power bi allows much customization of the axes.
So I figured a potential solution would be to convert months to percentages of time passed, create two separate graphs and place them on top of each other to show the comparison of sales.
Using percentages doesn't sound right here: one person's "productivity" in February will appear lower than another person's productivity in March just because February has 3 less days.
Just use [Date].[Day].
To answer the original question (even though it shouldn't be used for this), month progress percentage calculated column:
MonthProgress% =
var DaysinMonth = DAY(
IF(
MONTH(MyTable[date]) = 12,
DATE(YEAR(MyTable[date]) + 1,1,1),
DATE(YEAR(MyTable[date]), MONTH(MyTable[date]) + 1, 1)
) - 1
)
return MyTable[date].[Day]/DaysinMonth*100
Also check DAX functions PARALLELPERIOD and DATEADD.
This is the solution I settled on.
I customized the ranges for the x and y axes so they match.
For the y-axis, I simply put the range from 0 to 50+ our highest month.
For the x-axis, I created a column with the DAY function so I got a number assigned to each day of the month which allowed me to manually set the chart range from 0 to 31. I have asked another question on how to only get workdays.
I'm trying to apply a TOPN() visual filter to a Power BI sheet based on an Average Loan Amount measure. I want to see the top 5 employees with the highest average loan amount, ignoring employees who have disbursed 4 or fewer loans.
The problem I'm running into is that I don't get 5 rows returned, even though I've selected the top 5. I have to adjust the "TOPN" parameter (in the visuals) to include more than 5, just to get 5 rows.
This seems to be because when I have both the TOP5 average AND the loan count > 4 filters working, neither updates the other; that is, I can find the top 5 rows based on the average parameter, but once I include the "loan count > 4" condition, a few of the top 5 disappear, and they're not replaced by the runners-up to the original 5.
In the past, when I placed a top 5 filter for average and nothing came up, it was because all the top 5 entries all had a loan count of under 5. Once I relaxed the "TOPN" condition to be "TOP 52," I got 5 entries visible.
Does anyone know why this happens & how to fix it so I always get 5 rows returned?
EDITED TO ADD: For an example of the data, please click here. Please note that any employee with a loan count of 4 or less should be filtered out. I created the filter in PowerBI because the data sets are dynamic, and so are the filter results.
The fundamental problem is that you're applying 2 filters to the same visualization:
You only want to include employee's with a loan count of 5 or more
Of those, you want the 5 employees with the highest average loan amount
Power BI is applying both filters independently. So, it is taking the 5 employees with the highest average loan amount, and then removing 3 of them because their loan count is less than 5. I can imagine this is a common problem for people working with a Top N filter plus another filter.
One way to work around this (and I don't claim this is the only or even the best way), is to take into account the loan count before calculating the average.
For example, assuming you have the following two measures and the following data:
Loan Count = DISTINCTCOUNT(Employee[Loan Number])
Avg Loan Amt = AVERAGE(Employee[Loan Amount])
It's clear from the picture that Liz, Montgomery and Oscar are in the top 5 but have only 3 loans to their name.
Next, we can create a new measure that checks the Loan Count before calculating the average loan amount. If the loan count doesn't meet the threshold, you don't care about their average.
*Filtered Avg Loan Amt = IF([Loan Count] < 5, BLANK(), [Avg Loan Amt])
This creates the following result. Notice that Liz, Montgomery & Oscar now all have no average calculated because they don't have enough loans.
Now, you don't necessarily have to display the Filtered Avg Loan Amt measure on your table, but you can now use that measure in your Top N visual filter and that, by itself, will filter your table to the top 5 employees with a high enough loan count.
Notice that in my filters, I only have 1 filter (on Filtered Avg Loan Amt). I don't also need to filter to a loan count of 5 or greater. This results in the following top 5 employees:
I hope this solves the problem you're having!
Unrelated sidenote: if you're using this threshold of 5 in a few places, I would recommend sourcing the number from an external source (including possibly a disconnected table) rather than hard-coding 5 in the measure itself. That way, if someone decides that 5 isn't the right threshold, you only have to update it one place, rather than hunting through all your measures looking for the number 5. There's an article here on using a disconnected table so that end-users can pick the threshold themselves (though it could definitely be overkill for your situation): https://powerpivotpro.com/2013/08/moving-averages-controlled-by-slicer/