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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
LD
Frequent Visitor

Max Date by Condiction

Dear,

I have the following situation:

 

Raw Data

 

Column 1             Column 2             Column 3

ID 1                         Task 1                      Due Date A

ID 1                         Task 2                      Due Date B

ID 2                         Task 1                      Due Date C

ID 3                          Task 1                     Due Date D

ID 3                          Task 2                    Due Date D

ID 3                          Task 3                    Due Date E

ID n                            ......                            ......

 

I need to select the due max due date, excluding the task 2 and considering the Column 1.

The result is the association of Max due date to ID (1,2,3, n) excluding some condiction (by Column 2).

 

Thank you!!!!

LD

 

2 ACCEPTED SOLUTIONS
LD
Frequent Visitor

Hi @camargos88 ,

 

Yes:

 

Column1Column2Due DateMeasure
ID1Task Type AJan 31, 20March 31, 20
ID1Task type BMar 31, 20March 31, 20
ID2Task Type AAug 22,20Aug 22,20
ID3Task Type AApr 18, 20Apr 18, 20
ID3Task Type CJun 20, 20 Apr 18, 20
ID4Task Type AApr 18, 20May 05,20
ID4

Task Type B

May 05,20May 05,20
ID4Task Type CJun 15, 20May 05,20

 

so the task type C, is not considered into max value

 

Thank you

LD

View solution in original post

camargos88
Community Champion
Community Champion

@LD ,

 

Try this measure:

 

Measure = CALCULATE(MAX('Table'[Due Date]); FILTER(ALLEXCEPT('Table'; 'Table'[Column1]); 'Table'[Column2] <> "Task Type C"))
 
Ricardo


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

7 REPLIES 7
camargos88
Community Champion
Community Champion

Hi @LD ,

 

Try this measure:

Measure = CALCULATE(MAX('Table'[Column 3]); ALLEXCEPT('Table'; 'Table'[Column 1]))
 
directquery_sqlserverdb.png
 

If you consider it as a solution, please mark as a solution and kudos.

Ricardo

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



LD
Frequent Visitor

Dear @camargos88 ,

Command is quite ok..., Please, I need to exclude some row based on the Column2 (for example Task2 in Cl2)

 

Thank You

 

LD

camargos88
Community Champion
Community Champion

@LD ,

 

I didn't get what you want. 

 

Can you explain more ?

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



LD
Frequent Visitor

Yes, I'm sorry...

 

For example, I need to exclude (in ID3) the Due Date E because coming from Task3...

so all Task3 in every ID(1,2,3, n) will be not selected to determinate the max Due Date.

 

In the Example, the Due date should be "Due Date D"

 

I hope I was clear 🙂

 

Thank you!!!!

 

LD

camargos88
Community Champion
Community Champion

@LD ,

 

Can you post the expected result ?

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



LD
Frequent Visitor

Hi @camargos88 ,

 

Yes:

 

Column1Column2Due DateMeasure
ID1Task Type AJan 31, 20March 31, 20
ID1Task type BMar 31, 20March 31, 20
ID2Task Type AAug 22,20Aug 22,20
ID3Task Type AApr 18, 20Apr 18, 20
ID3Task Type CJun 20, 20 Apr 18, 20
ID4Task Type AApr 18, 20May 05,20
ID4

Task Type B

May 05,20May 05,20
ID4Task Type CJun 15, 20May 05,20

 

so the task type C, is not considered into max value

 

Thank you

LD

camargos88
Community Champion
Community Champion

@LD ,

 

Try this measure:

 

Measure = CALCULATE(MAX('Table'[Due Date]); FILTER(ALLEXCEPT('Table'; 'Table'[Column1]); 'Table'[Column2] <> "Task Type C"))
 
Ricardo


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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