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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Filtering a table with date dependency

Hello, I am relatively new to Power BI and have already done some research on my problem. However, I have not yet found a solution that works.
I have the following table:

SNDateStatus
11108.01.2022 06:55failed
11108.01.2022 07:00passed
22208.01.2022 07:02passed
33308.01.2022 07:03failed
33308.01.2022 07:04failed
33308.01.2022 07:05passed
44408.01.2022 07:10failed
44408.01.2022 07:12failed
55508.01.2022 07:15passed
66608.01.2022 07:20passed

 

Now I have the following requirements:
1) Filter and display a new table, which looks like this:

 

SNDateStatus
22208.01.2022 07:02passed
55508.01.2022 07:15passed
66608.01.2022 07:20passed

 

Only the SNs that have the status passed at the first attempt should be displayed. I have tried it over different nested functions, without success. Getting the date into the right dependency is difficult for me.

 

2) Count the rows in the filtered table (probably as measure with "CountRows"). The Result should be = 3 in my example. Should be simple:-)

 

Thanks already for your support

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

Hi @Anonymous ,

According to your description, here's my solution. I have two methods.

Method 1

1.Create a new table.

vkalyjmsft_0-1645497911419.png

Table 2 = 
FILTER (
    ALL ( 'Table' ),
    MINX (
        FILTER ( ALL ( 'Table' ), 'Table'[SN] = EARLIER ( 'Table'[SN] ) ),
        'Table'[Status]
    ) = "passed"
)

Get the expected table.

vkalyjmsft_1-1645497989033.png

2.Create a measure.

Count' = COUNTROWS('Table 2')

Get the correct count.

vkalyjmsft_2-1645498027460.png

Method 2

1. Create a measure.

Check =
IF (
    MINX (
        FILTER ( ALL ( 'Table' ), 'Table'[SN] = MAX ( 'Table'[SN] ) ),
        'Table'[Status]
    ) = "passed",
    1,
    0
)

Select the visual, put the check measure in the visual filter, then select the value is 1.

vkalyjmsft_3-1645498176597.png

Get the expected result.

vkalyjmsft_4-1645498262012.png

2.Create another measure.

Count = 
CALCULATE (
    COUNT ( 'Table'[SN] ),
    FILTER (
        ALL ( 'Table' ),
        MINX (
            FILTER ( ALL ( 'Table' ), 'Table'[SN] = EARLIER ( 'Table'[SN] ) ),
            'Table'[Status]
        ) = "passed"
    )
)

Get the correct count.

vkalyjmsft_5-1645498315960.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here's my solution. I have two methods.

Method 1

1.Create a new table.

vkalyjmsft_0-1645497911419.png

Table 2 = 
FILTER (
    ALL ( 'Table' ),
    MINX (
        FILTER ( ALL ( 'Table' ), 'Table'[SN] = EARLIER ( 'Table'[SN] ) ),
        'Table'[Status]
    ) = "passed"
)

Get the expected table.

vkalyjmsft_1-1645497989033.png

2.Create a measure.

Count' = COUNTROWS('Table 2')

Get the correct count.

vkalyjmsft_2-1645498027460.png

Method 2

1. Create a measure.

Check =
IF (
    MINX (
        FILTER ( ALL ( 'Table' ), 'Table'[SN] = MAX ( 'Table'[SN] ) ),
        'Table'[Status]
    ) = "passed",
    1,
    0
)

Select the visual, put the check measure in the visual filter, then select the value is 1.

vkalyjmsft_3-1645498176597.png

Get the expected result.

vkalyjmsft_4-1645498262012.png

2.Create another measure.

Count = 
CALCULATE (
    COUNT ( 'Table'[SN] ),
    FILTER (
        ALL ( 'Table' ),
        MINX (
            FILTER ( ALL ( 'Table' ), 'Table'[SN] = EARLIER ( 'Table'[SN] ) ),
            'Table'[Status]
        ) = "passed"
    )
)

Get the correct count.

vkalyjmsft_5-1645498315960.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

amitchandak
Super User
Super User

@Anonymous , Create a new column like this and use that as filter

 


new column =
var _min = minx(filter(Table, Table[SN] = earlier([SN])),[DAte])
return
if([Date] =_min && [Status] = "passed" ,1, 0 )

 

or try a measure like

new measure =
var _min = minx(filter(allselected(Table), Table[SN] = max([SN])),[DAte])
return
calculate(max(Table[Status]), filter(Table, Table[Date] =_max ))

Anonymous
Not applicable

Hi @amitchandak,

Thanks for your suggestion. The idea with the additional column is an interesting solution. But I mainly need a filtered table as a result and not a additional column. The measure should count the rows of the filtered table afterwards.
Do you have another idea for this?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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