Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Sania-F
Contributor

VALUES function with HASONEVALUE and SUMX iterator function

sales commission iterator =
SUMX(
    VALUES('Sales Territory'[Region]),
    CALCULATE(
        [Revenue]
        * IF(
            VALUES('Sales Territory'[Country]) = "United States",
            0.15,
            0.1
        )
    )
)
----------------------------------------------------------------------------------
sales commission = [Revenue] *
if(HASONEVALUE('Sales Territory'[Country]),
 IF(VALUES('Sales Territory'[Country]) = "United States", 0.15,0.1))
-----------------------------------------------------------------------------------
  • Iterator version = correct when multiple values exist, because it loops through each row and applies the right logic.

  • Simple version = works only when the filter context guarantees one country at a time. If multiple exist, it miscalculates.


  • In sales commission iterator, SUMX iterates through each region, evaluates [Revenue] * 0.1, then sums up.

  • In sales commission, you’re multiplying the total [Revenue] in context by 0.1.


Rule of thumb:

  • Use simple measure if your business rule applies a single rate per filter context.

  • Use iterator (SUMX) when you need row-by-row logic, e.g., different commission rates for different countries/products.

2 REPLIES 2
FBergamaschi
Contributor III

This is a blog for asking for support, if you want to explain DAX you can consider other blogs

v-sdhruv
Honored Contributor

Hi  @Sania-F ,
Thank you for sharing this. This kind of post is incredibly valuable to the community. Consider turning this into a blog post so others can benefit from your experience more easily
Power BI Community Blog - Microsoft Fabric Community


Thank You!

Helpful resources

Announcements
Top Solution Authors
Users online (8,586)