Forum Discussion
MandoMongo
2 years agoRegular Visitor
Total Sum by Product Difficulty
* EDIT: I think I have it but perhaps not working as it should Average Sale by Item Type = AVERAGEX( VALUES(Warehouse_and_Retail_Sales[ITEM TYPE]), [Total Retail Sales] ) Total Sale b...
- 2 years ago
So to give you a potential explanation of what the measure do i'll tell you the following:
the average of 10+12 = 22 meaning average is 22/2 = 11
This is what happens when you use the measure
AVERAGE(Warehouse_and_Retail_Sales[RETAIL SALES])The column is the only variable used in the calculation. When creating a visual the calculation is partinioned by the product group as seen in scenario 3.With the other measure you do the following:you calculate the Sum of sales which for example REF = 380.You then divide 380 by the number of times it shows up. However in this case only 380 is known so it does: 380/1 = 380. meaning the average shown is 380.The method i mentioned earlier does 10+ 12 = 22 / 2 = 12 Average.Something similar is happening with SUMX()What we usually do in SQL and DAX is calculate over a column: RETAIL_SALES and then partition it over a group. in SQL we do GROUP BY and in Power BI this is done automatically by selecting different components in a visualKR,--Troekoe
Troekoe
2 years agoFrequent Visitor
Yo!
I am assuming the calculation you are trying to do looks similar to this:
| Product type | SUM |
| A | 10 |
| B | 5 |
| C | 20 |
| D | 100 |
The nice thing about Power BI is that it calculates a group for you in visuals automatically.
If you were to create a measure = SUM(Your_Table[Sales]) and use this measure with your column: Warehouse_and_Retail_Sales[ITEM TYPE] in a visual.
It will automatically show you the sum for each group.
Look at this example with the data and measure i just told you about:
Hope this helps!
--Troekoe