cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

how to filter the data returned by a previous filter

I have two tables with the below structure

SalesData                  ServiceData

Vehicle                       Vehicle

SellDate                     SDate

 

The SellDate is the date that vehicle is sold and the SDate is the date of service.

I have a filter that return all vehicles sold between two dates.

I want to perform another filter on the result of the first filter and display the distinctcount of vehicles that came back for service

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper I
Helper I

Re: how to filter the data returned by a previous filter

i ended up using the IN operator and it gave me what i wanted

 

Serviced = CALCULATE(
DISTINCTCOUNT(HISTDTL[VEHICLE]),
HISTDTL[VEHICLE] IN
VALUES(VEHICLE[VEHICLE]
)
)

View solution in original post

6 REPLIES 6
Highlighted
Super User IV
Super User IV

Re: how to filter the data returned by a previous filter

Hi @elie_abidaher 

 

Can you provide a data sample and expected outcome?

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

 

Highlighted
Helper I
Helper I

Re: how to filter the data returned by a previous filter

this is a download link with sample data

https://masaood-my.sharepoint.com/:u:/p/elie_abidaher/EYAckvOvHAJMqTUIhvntD7IBdJa2riAtxuH6yS9XZRh6hw...

 

now in this report of you select period 1 from first table, then it displays all data from table 3, the correct outcome should be row S4 only

Highlighted
Super User IV
Super User IV

Re: how to filter the data returned by a previous filter

Hi @elie_abidaher 

 

Try this Measure.

Measure = 
VAR __start = MIN( 'Table'[StartDate] )
VAR __end = MAX( 'Table'[EndDate] )
RETURN 
CALCULATE(
    COUNTROWS( 'Table (3)' ),
    'Table (3)'[SDate] >= __start,
    'Table (3)'[SDate] <= __end 
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

Highlighted
Helper I
Helper I

Re: how to filter the data returned by a previous filter

this will return all the rows in table3 that matches the date criteria and will totaly neglect to check if the vehicle is sold in that period as well from table2

Highlighted
Helper I
Helper I

Re: how to filter the data returned by a previous filter

please download the new updated report from the previous link

if you select Period 1 from Table1 then you should get 2 rows returned in table 2 and 1 row in table3, but it is returning 2 rows in table3

S1 is serviced in 2019 but sold in 2015 so it shouldn't appear

Highlighted
Helper I
Helper I

Re: how to filter the data returned by a previous filter

i ended up using the IN operator and it gave me what i wanted

 

Serviced = CALCULATE(
DISTINCTCOUNT(HISTDTL[VEHICLE]),
HISTDTL[VEHICLE] IN
VALUES(VEHICLE[VEHICLE]
)
)

View solution in original post

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors