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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
elie_abidaher
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
elie_abidaher
Helper I
Helper I

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
elie_abidaher
Helper I
Helper I

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]
)
)
Mariusz
Community Champion
Community Champion

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.

 

 

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

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.

 

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

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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