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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ratercero
Helper III
Helper III

Filter Query (or create new table) based on first (date) duplicate and values of 2 columns

Hello Everyone,
I've tried my best to find the best solution for my issue on the forums, but got into a dead end, so im asking for help from scratch. instead of modifying my attempts, here it goes:
I have a defect table and intend to filter my query or create a new table acording the following criteria:

First date of defect, no duplicate batch#, Process = Tinto , State <> Aprobado

 

Table for reference:

 

Capture.JPG

Thank You

1 ACCEPTED SOLUTION

Aha, I think I follow now

 

Table 3 = 
VAR T1 = SUMMARIZE('Table','Table'[BATCH#],"First Date" , MIN('Table'[DATE]))
VAR T2 = FILTER(
    NATURALINNERJOIN('Table',T1),[STATE]<> "Aprobado" && [PROCESS]="Tinto" && [First Date] = [DATE])
RETURN T2

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

7 REPLIES 7
Phil_Seamark
Employee
Employee

Im not sure if I fully understand your needs but this is my interpretation.  Let me know how close I am.

 

Table 2 = 

var T1 = FILTER(
                'Table',
                'Table'[PROCESS]="Tinto"
                && 'Table'[STATE] <> "Aprobado"
                )
                
var T2 = SUMMARIZE(
                T1,
                'Table'[BATCH#] , 
		"Max Date" , 
		MAX('Table'[DATE]))               
return NATURALINNERJOIN(T1,T2)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hello Phil,

This is close but not exactly what I'm looking for, this is my logical thinking of how it should happen:

 

First I need to find the earliest a batch is in the data, no matter if it complies with the other filtered criteria, afterwards it should filter only leave on the table the ones that comply. 

 

Basically im looking for all batches that in their first input comply with the criteria status<> "aprobado" and process  ="Tinto".

 

This is what i got with your suggested formula:

 Capture2.JPG

 They comply with the filters but have duplicate batch #.

I hope I explained myself properly this time.

Any more thougths?

Thanks

 

Is this getting closer?

 

Table 3 = 
VAR T1 = SUMMARIZE('Table','Table'[BATCH#],"First Date" , MIN('Table'[DATE]))
VAR T2 = FILTER(
    NATURALINNERJOIN('Table',T1),[STATE]<> "Aprobado" && [PROCESS]="Tinto")
RETURN SUMMARIZE(T2,'Table'[BATCH#] , "Batches" , COUNTROWS('Table') , "First Date" , min('Table'[DATE]))

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Can you please post a mock-up of what the result table should look like?  

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Same as the one in my last post but only with the top result which is the ealiest date:


Capture2 - Copy.JPG

 

 

 

Aha, I think I follow now

 

Table 3 = 
VAR T1 = SUMMARIZE('Table','Table'[BATCH#],"First Date" , MIN('Table'[DATE]))
VAR T2 = FILTER(
    NATURALINNERJOIN('Table',T1),[STATE]<> "Aprobado" && [PROCESS]="Tinto" && [First Date] = [DATE])
RETURN T2

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thank you!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.