Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Probably missing something very basic about how measures work.
I have a measure to calculate inventory on hand based on table inventory_v2.
When reporting a table for August I get:
When reporting September, I get:
Both tables seem to be ok. However when I select both months, I get:
which shows data from both months, but when calculating totals only considers September data.
The expected result would have been to get a table identical to September since it is the latest month.
Would much appreciate your help in understanding why the difference vs expected and should I modify my measures to get the expected result.
Some additional info:
"label" column is a calculated column based on inventory price
Inventory on hand is calculated as follows:
inv_on_hand_v5 =
VAR latest_date = CALCULATE(MAX(inventory_v2[inventory_date]))
VAR inv_currency = CALCULATE(SUMX(inventory_v2,(inventory_v2[inventory_amount]) / inventory_v2[relatedrate]), FILTER((inventory_v2),latest_date==inventory_v2[inventory_date]))
VAR inv_units = CALCULATE(SUMX(inventory_v2,(inventory_v2[inventory_qty])), FILTER((inventory_v2),latest_date==inventory_v2[inventory_date]))
RETURN inv_currency
This is the typical "total sum" problem with dax:
https://www.sqlbi.com/articles/why-power-bi-totals-might-seem-inaccurate/
YOU can fix it like this:
RETURN if(hasonefilter(label)=TRUE;inv_currency;X)
The problem can be that you choose with
latest_date = CALCULATE(MAX(inventory_v2[inventory_date]))
only the last date in sept in the last row.
One idea:
inv_on_hand_v5 =
VAR earlist_date = CALCULATE(MIN(inventory_v2[inventory_date]))
VAR latest_date = CALCULATE(MAX(inventory_v2[inventory_date]))
VAR inv_currency = CALCULATE(SUMX(inventory_v2,(inventory_v2[inventory_amount]) / inventory_v2[relatedrate]), FILTER((inventory_v2),latest_date>=inventory_v2[inventory_date])&& earlist_date<=inventory_v2[inventory_date]))
VAR inv_units = CALCULATE(SUMX(inventory_v2,(inventory_v2[inventory_qty])), FILTER((inventory_v2),latest_date==inventory_v2[inventory_date]))
RETURN inv_currency
Proud to be a Super User!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
97 | |
69 | |
46 | |
39 | |
33 |
User | Count |
---|---|
163 | |
110 | |
61 | |
51 | |
40 |