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

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

Reply
DennisSchlein
Helper III
Helper III

Beginner - conditional filtering?

Hi 

Bare with me, i'm all new to Power BI.

 

I have a dataset that needs to be filtered, based on a certain value.

CriteriaScanDateScanTypeIdRequested pickup date
112-07-2021null01-07-2021
112-07-20211401-07-2021
1null1501-07-2021
1null1601-07-2021
1null1401-07-2021
1nullnull01-07-2021
201-07-2021301-07-2021
203-06-2021nullnull
201-07-20211601-07-2021
203-06-20211401-07-2021
201-07-20211601-07-2021
203-06-20211null

 

I wanna have a filter on Criteria.

If Criteria is 1 - Then Requested pickup date is not null
Else if

Criteria is 2 - Then scan date is not null and scan type id is 14,15,16.


But the basic of how to do this, is this a meassure? Do I split my dataset into two, or?

Thanks in advance
Kind regards

 

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @DennisSchlein 

 

If you want to filter data before you use it in desktop, you can create a custom step in pq.

Like this:

= Table.SelectRows(#"Changed Type1", each  [Criteria]=1 and [Requested pickup date]<>null or [Criteria]=2 and [ScanDate]<>null and List.Contains({14,15,16},[ScanTypeId]) 
/If you don’t want to limit other situations/
or [Criteria]>2)

vjaneygmsft_0-1626245260610.png

If you want to use it in table visual, you can create measure then use it in filter pane to filter data.

Like this:

Measure =
IF (
    MAX ( 'Table (2)'[Criteria] ) = 1
        && MAX ( 'Table (2)'[Requested pickup date] ) <> BLANK (),
    1,
    IF (
        MAX ( 'Table (2)'[Criteria] ) = 2
            && MAX ( 'Table (2)'[ScanDate] ) <> BLANK ()
            && DISTINCT ( 'Table (2)'[ScanTypeId] ) IN { 14, 15, 16 },
        1,
        0
    )
)

vjaneygmsft_1-1626245698525.png

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi, @DennisSchlein 

 

If you want to filter data before you use it in desktop, you can create a custom step in pq.

Like this:

= Table.SelectRows(#"Changed Type1", each  [Criteria]=1 and [Requested pickup date]<>null or [Criteria]=2 and [ScanDate]<>null and List.Contains({14,15,16},[ScanTypeId]) 
/If you don’t want to limit other situations/
or [Criteria]>2)

vjaneygmsft_0-1626245260610.png

If you want to use it in table visual, you can create measure then use it in filter pane to filter data.

Like this:

Measure =
IF (
    MAX ( 'Table (2)'[Criteria] ) = 1
        && MAX ( 'Table (2)'[Requested pickup date] ) <> BLANK (),
    1,
    IF (
        MAX ( 'Table (2)'[Criteria] ) = 2
            && MAX ( 'Table (2)'[ScanDate] ) <> BLANK ()
            && DISTINCT ( 'Table (2)'[ScanTypeId] ) IN { 14, 15, 16 },
        1,
        0
    )
)

vjaneygmsft_1-1626245698525.png

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is excactly what I was looking for, and it works like a charm! 

Thank you very much for the effort! 

emilmorkeberg
Frequent Visitor

Hi,

 

You can add a calculated column to your table and use a combination of nested IFS and a SWITCH() to define the output of the column and use that to filter whatever you want. Go to "Modeling -> New Column" in your report and try using the following (you need to replace 'TableName')

 

ColumnFilter = 

// VARIABLES
var SelectedCriteria = SELECTEDVALUE('TableName'[Criteria])
var SelectedPickupDate = SELECTEDVALUE('TableName'[Requested pickup date])
var SelectedScanDate = SELECTEDVALUE('TableName'[ScanDate])
var SelectedScanTypeId = SELECTEDVALUE('TableName'[ScanTypeId])

Return

// FORMULA

IF(SelectedCriteria = 1,IF(SelectedPickupDate <> "null","Include","Exclude"),

IF(SelectedCriteria = 2,
SWITCH(TRUE(),
SelectedScanDate <> "null","Include",
SelectedScanTypeId = 14,"Include",
SelectedScanTypeId = 15,"Include",
SelectedScanTypeId = 15,"Include",
"Exclude"),"Exclude")

 

 

Afterwards, you can use this new calculated column to exclude instances that doesn't meet your defined requirements, by filtering page/visual with "Include".

If this doesn't solve your problem, please specify your issue.

 

More about the Switch function here: https://docs.microsoft.com/en-us/dax/switch-function-dax

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.