The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi,
I'm new to Power BI and DAX and have made a newbie mistake in totalling a measure on a report I was creating. I've fixed it, but still don't understand why it needs to be this way... hoping someone can help explain it to me.
The basic requirement is to report on product sales - the average quantity sold per month over 6 months, and what the cost would be to purchase 1 month of stock at the current average cost.
My data model is as follows:
To explain the tables:
K8_OS_01_BUFFR is where all sales transactions are held, line by line.
K8_BR_01_PRODF is the product file where cost is held.
K8_CF_01_CUSTF is customers (not relevant for this question)
To begin with I set up a table of product, sum of quantity, monthly average sales and average cost. My monthly average sales is a measure on K8_OS_01_BUFFR:
Monthly Average = SUM(K8_OS_01_BUFFR[QUANTITY]) / 6
I then created another measure, Purchase Cost 1 Month, like so:
Purchase Cost 1 month = [Monthly Average] * AVERAGE(K8_OS_01_BUFFR[Average Cost])
This gives me the correct purchase cost on a line by line basis, but an incorrect total as you will see below (simplified to two products only, product description redacted for commercial confidentiality reasons)
After much searching and following this thread https://community.powerbi.com/t5/Desktop/Sum-of-a-calculated-measure-column/td-p/446458 I have discovered that I need to use SUMX and set up my measure like this
CORRECT Purchase Cost 1 Month = SUMX(K8_OS_01_BUFFR,(K8_OS_01_BUFFR[QUANTITY]/6) * K8_OS_01_BUFFR[Average Cost])
However I also thought that I should be able to use my Monthly Average measure here and set it up like this
Purch Cost with Measure = SUMX(K8_OS_01_BUFFR,[Monthly Average] * K8_OS_01_BUFFR[Average Cost])
but it doesn't work:
Please can someone help me understand the following:
Thanks 🙂
A sum of averages is different from an average of sums.
First step is to be clear on what you actually want to compute
Second step is to implement that well defined (and confirmed with your business users) logic in DAX.
User | Count |
---|---|
28 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
35 | |
14 | |
12 | |
9 | |
7 |