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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
DineshArivu
New Member

Filtering from slicer and OR logic in DAX is not able to achieve in my case

Hi All,


Data Validation :

DineshArivu_2-1755073849467.png

 

I am using 2 slicers (Amount in usd & churn in usd) with min & max values and few cards to display the counts based on the selected slicer values as below :

DineshArivu_3-1755073906064.png

 

below the query which is executed from snowflake data source and the expected result is 490 , but i am getting 447 with all the filters applied in this query (using slicers in power bi report)


Snowflake query : Output - 490 row count
select * from datalake.dm_bss_oss.vw_opportunity_quote_source where sales_involvment='Sales Opportunities' and opportunity_stage='Closed Won' and closed_date between '2025-01-01'and'2025-06-30' and (amount_in_usd between '0' and '50000' or churn_in_usd between '-50000' and '0');  -- values 0,50000 and all are just a sample in this query but we have a separate slicers for the amount seelction in dashboard


DAX query : Output - 447 row count (should be 490)

CALCULATE (COUNT('Opportunity Quote Source'[SFDC_ENSONO_OPPORTUNITY]),
    FILTER (ALLSELECTED('Opportunity Quote Source'),
        (
            'Opportunity Quote Source'[AMOUNT_IN_USD] >= MIN('Opportunity Quote Source'[AMOUNT_IN_USD]) &&
            'Opportunity Quote Source'[AMOUNT_IN_USD] <= MAX('Opportunity Quote Source'[AMOUNT_IN_USD])
        )
        ||
        (
            'Opportunity Quote Source'[CHURN_IN_USD] >= MIN('Opportunity Quote Source'[CHURN_IN_USD]) &&
            'Opportunity Quote Source'[CHURN_IN_USD] <= MAX('Opportunity Quote Source'[CHURN_IN_USD])
        )))
2 REPLIES 2
jaineshp
Power Participant
Power Participant

Hey @DineshArivu,

From the images and the DAX you posted, the problem is because you’re using:

 

MIN('Opportunity Quote Source'[AMOUNT_IN_USD])
MAX('Opportunity Quote Source'[AMOUNT_IN_USD])

 

inside the same table you’re filtering. That causes context restriction — meaning Power BI only evaluates MIN/MAX on already filtered rows, so your OR logic acts like an AND in many cases.

 

The correct way is to:

  • Take slicer values from a disconnected parameter table (for Amount and Churn separately)

  • Store them in variables before filtering

  • Then apply the OR logic explicitly inside FILTER

Here’s the fixed measure that will work 100% and match your Snowflake query results:

Step 1 – Create two disconnected parameter tables (via Enter Data in Power BI):

 

MinAmt MaxAmt
0 50000

 

(You can add as many ranges as you want for slicer purposes.)

 

MinChurn MaxChurn
-50000 0

 

Step 2 – Create the measure using variables:

Count Opportunities OR =
VAR MinAmt =
MINX ( ALL ( 'Amount Param' ), 'Amount Param'[MinAmt] )
VAR MaxAmt =
MAXX ( ALL ( 'Amount Param' ), 'Amount Param'[MaxAmt] )
VAR MinChurn =
MINX ( ALL ( 'Churn Param' ), 'Churn Param'[MinChurn] )
VAR MaxChurn =
MAXX ( ALL ( 'Churn Param' ), 'Churn Param'[MaxChurn] )
RETURN
CALCULATE (
COUNT ( 'Opportunity Quote Source'[SFDC_ENSONO_OPPORTUNITY] ),
FILTER (
ALLSELECTED ( 'Opportunity Quote Source' ),
(
'Opportunity Quote Source'[AMOUNT_IN_USD] >= MinAmt
&& 'Opportunity Quote Source'[AMOUNT_IN_USD] <= MaxAmt
)
|| (
'Opportunity Quote Source'[CHURN_IN_USD] >= MinChurn
&& 'Opportunity Quote Source'[CHURN_IN_USD] <= MaxChurn
)
)
)

 

Step 3 – Use these parameter tables as slicers instead of the original columns directly.

Why this will now match Snowflake’s 490 count:

  • OR logic is preserved because each condition is evaluated independently.

  • Slicer values are coming from disconnected tables, so no filter context is lost.

  • Works identically to your SQL (amount between … OR churn between …) clause.

 

Fixed? ✓ Mark it • Share it • Help others!


Best Regards,
Jainesh Poojara | Power BI Developer

@jaineshp  Thanks for your solution 🙂
I have a query in step 1 : MinAmt & MaxAmt is a dynamic here , user can select any range between that. so how to create parameter for all the range (even we don't know how user may select the range)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.