Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
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! |
|
User | Count |
---|---|
12 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
24 | |
19 | |
14 | |
10 | |
7 |