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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
qqqube
New Member

question about the formula of hasonevalue

dax-power-bi-modify-filter/4-examine-filter-context 

in this training module, it gives us an example of HAVEONEVALUE formula as follows 

 

 

Sales Commission =
[Revenue]
    * IF(
        HASONEVALUE('Sales Territory'[Country]),
        IF(
            VALUES('Sales Territory'[Country]) = "United States",
            0.15,
            0.1
        )
    )

 

112.png and it tell us that the reason why total of sales commission is blank is because HASONEVALUE('Sales Territory'[Country]) return FALSE. 

so I tried to change it to HASONEVALUE('Sales Territory'[Region]) as the values in [Region] column are unique. but still total of sales commission is blank.

 

Please explain why. thx.

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@qqqube The HASONEVALUE function returns TRUE only when there is exactly one distinct value in the specified column within the current filter context. When you are looking at the total of the sales commission, the filter context typically includes multiple values from the 'Sales Territory'[Region] column, which causes HASONEVALUE to return FALSE.

 

 

Filter Context at Total Level: When calculating the total, the filter context includes all regions, not just one. Therefore, HASONEVALUE('Sales Territory'[Region]) returns FALSE because there are multiple regions in the context of the total.

 

Blank Result: Since HASONEVALUE returns FALSE, the IF condition is not met, and the formula does not proceed to calculate the commission, resulting in a blank value for the total.

 

To address this, you can modify the formula to handle the total calculation separately. One way to do this is by using the SUMX function to iterate over each row and calculate the commission individually, then sum the results:




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

1 REPLY 1
bhanu_gautam
Super User
Super User

@qqqube The HASONEVALUE function returns TRUE only when there is exactly one distinct value in the specified column within the current filter context. When you are looking at the total of the sales commission, the filter context typically includes multiple values from the 'Sales Territory'[Region] column, which causes HASONEVALUE to return FALSE.

 

 

Filter Context at Total Level: When calculating the total, the filter context includes all regions, not just one. Therefore, HASONEVALUE('Sales Territory'[Region]) returns FALSE because there are multiple regions in the context of the total.

 

Blank Result: Since HASONEVALUE returns FALSE, the IF condition is not met, and the formula does not proceed to calculate the commission, resulting in a blank value for the total.

 

To address this, you can modify the formula to handle the total calculation separately. One way to do this is by using the SUMX function to iterate over each row and calculate the commission individually, then sum the results:




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.