Forum Discussion
DAX not working
- Anonymous1 year ago
Hi Anees91 ,
I made simple samples and you can check the results below:Table 2 = SUMMARIZE('Table',[Category]) Measure = var _s = SELECTEDVALUE('Table 2'[Category]) var _sum = COUNT('Table'[ID]) var _total = CALCULATE(COUNT('Table'[ID]),REMOVEFILTERS('Table'[Category]),FILTER('Table',[Fail]="Yes")) var _selecet = CALCULATE(COUNT('Table'[ID]),FILTER('Table',[Fail]="Yes"&&[Category]=_s)) RETURN IF(HASONEFILTER('Table 2'[Category]),1-DIVIDE(_selecet,_sum),1-DIVIDE(_total,_sum))An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott ChangIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Anees91 ,
The issue you’re encountering arises from the filter context when interacting with multiple visuals, particularly the bar chart and the gauge visual, combined with the date slicer. The discrepancy occurs because your Service Success measure uses ALLSELECTED and REMOVEFILTERS, which can sometimes reset or alter the filter context unexpectedly.
To address this, you can refine your measure to ensure consistent behavior across all visuals. Modify the measure as follows:
Service Success =
VAR Numerator = CALCULATE(
COUNT('Volume'[Failure.ConsignmentId]),
REMOVEFILTERS('Volume'[Failure.SFCCode])
)
VAR Denominator = CALCULATE(
COUNT('Volume'[ConsignmentId]),
REMOVEFILTERS('Volume'[Failure.SFCCode])
)
RETURN
IF(
Denominator = 0,
BLANK(),
1 - (Numerator / Denominator)
)
This updated formula ensures that the SFCCode filter is removed consistently, allowing the measure to correctly calculate percentages even when interacting with slicers or visuals. Additionally, verify that the date slicer’s filtering context is applied correctly to the visuals by reviewing the relationships between your date column and the Volume table.
Make sure the interactions between the visuals are properly configured in Power BI. Check that the bar chart filters the gauge visual as intended while the date slicer applies to both the bar chart and the gauge visual. You can do this by going into "Edit Interactions" and adjusting the behavior to suit your needs.
If the problem persists, you can experiment with removing REMOVEFILTERS in the measure to see if it resolves the issue. Testing the gauge visual with and without slicer interaction can help pinpoint where the filter context is being lost. Additionally, using the Performance Analyzer in Power BI can provide insight into how the filter context is being applied during interactions. This will help ensure that all visuals are synchronized and displaying the correct calculations.
Best regards,