Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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
)
)
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.
Solved! Go to Solution.
@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:
Proud to be a 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:
Proud to be a Super User! |
|
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
18 | |
17 | |
17 | |
15 |
User | Count |
---|---|
28 | |
27 | |
18 | |
14 | |
13 |