Forum Discussion
cj_oat
1 year agoHelper I
Value missing from Matrix table after using SUMX
Hi guys, I'm trying to create Measure to count other Measure based on conditions below, Qualified Flag Count = VAR _ActiveFlag = if ([ActiveFlag]>0 , 1 , BLANK()) VAR _SalesInv = if ([Cum...
FarhanJeelani
1 year agoSuper User
Hi cj_oat ,
The issue you’re facing is due to how SUMX works within the row context. The problem arises because _QualifiedFlag is being evaluated in the wrong context when you use SUMX. To resolve this and get the correct results for both individual cells and the totals, you need to make sure the measure respects the context correctly.
Here’s the corrected measure:
Qualified Flag Count =
SUMX(
'Table',
VAR _ActiveFlag = IF([ActiveFlag] > 0, 1, BLANK())
VAR _SalesInv = IF([Cumulative Sales] + [Inventory] > 0, 1, BLANK())
VAR _QualifiedFlag = IF(_ActiveFlag + _SalesInv = 2, 1, BLANK())
RETURN _QualifiedFlag
)Key Adjustments:
Moving Calculations Inside SUMX:
- _ActiveFlag, _SalesInv, and _QualifiedFlag are now evaluated per row in the table context within SUMX.
Ensuring Proper Context:
- By defining the logic inside the SUMX, the calculation works for each row of the table correctly, and the results can be aggregated as expected.
Check Table Rows:
- Ensure that 'Table' contains all relevant rows for the months (e.g., ensure rows for June and July exist in the table, even if some fields are blank).
Debugging Tips:
- Use a calculated column to debug _ActiveFlag and _SalesInv if needed to ensure these intermediate values are being computed correctly for the months in question.
- Test _QualifiedFlag independently to confirm it produces the expected results for each row.
Why Your Initial Measure Failed:
- In the first version of your measure, _QualifiedFlag was returning BLANK() for certain months because the SUMX function was iterating over the table but _QualifiedFlag was evaluated outside of the row context.
Let me know if this works!
Please mark this as solution if it helps. Appreciate Kudos.