Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have 2 tables... One that holds my sales stats per day. And another table that I'm using that has all my Date/Week/Month columns and created a realtionship between my Sales table and my Calendar table based on the Date column in my Sales table and the Date column in my Calendar table.
I'm now trying create a DAX that will give me an average sales, based on a slicer of "weeks" (and I'm choosing 3 weeks), and grouping the sales by Day of Week (Sun, Mon, Tue, Wed, Th, Fri, Sat).
When I use the Clustered Column Chart, it automatically sums the sales per weekday, and does not allow me to do or chose an "average" as a choice.
Any ideas?
@Anonymous , if you have created as the measure then it will not give an option to change the aggregation
sales measure = sum(sales[sales])
if it giving/showing sum then it should give an average. If it is not showing both means data type is not number, change it.
If sorting is an issue. you should use a sort column.
https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column
Thanks. You're absolutely right, looking at the sales, I did have it set as a measure based on the original data table I am calculating to.
AllSales = Calculate(sum(SalesData[TotalSalesValue]),SalesData[ProductSalesName)="Sales")
And I think that's where I'm stuck. Because it is a measure.
When using that measure inside the graph, grouping it by WeekDay, and a slicer that is choosing how many weeks to calculate, that's where I'm stuck in trying get an average for each weekday, instead of a total for each weekday.
Does this expression give your expected result? It should do same filter on ProductSalesName but average instead of Sum.
AllSales = Calculate(Average(SalesData[TotalSalesValue]),SalesData[ProductSalesName)="Sales")
Or, if you want average per week you can reference the measure above in
Avg Weekly Sales = AVERAGEX(VALUES('Calendar'[Week'), [AllSales])
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks mahoneypat,
So I did try the
AllSales = Calculate(Average(SalesData[TotalSalesValue]),SalesData[ProductSalesName)="Sales")
And based on how the SalesData table is laid out, at a transactional level (each day, each salesperson,productsales name, and salesvalue), it is averaging the sales, but it looks like per sales person, instead of the total sales for that day..
So the total sales per each Sunday was:
Sunday 1 = 4143
Sunday 2 = 2861
Sunday 3 = 3390
The average for those 3 sundays should be: 3464
Doing the DAX above, it's giving me 17, which is more the average per sales agent, instead of the total for Sunday..
Hi @Anonymous ,
Not certain what did 17 represent under this measure. Could you consider sharing some sample data or sample file for further discussion? It would let us help you better to solve this issue.
Best Regards,
Yingjie Li
@Anonymous This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149
The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.
So, Greg_Deckler,
Using this layout for AverageX
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
Could it then look something like this:
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
79 | |
74 | |
56 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |