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
Rajat529
New Member

Conditional Column

Hi There

 

I m new to Power BI and need Dax to achieve the output below.

 

In the dateset i want to add new column output where i want leads from the latest date of same ids and for the earlier date output should be blank as shown below.

 

DateLeadsIdOutput
9/12/2022561 
9/19/2022231 
9/26/2022451 
10/3/2022211 
10/10/2022221 
10/17/2022231 
11/24/202245145
9/12/2022562 
9/19/2022232 
9/26/2022452 
10/3/2022212 
10/10/2022222 
10/17/2022232 
11/24/202256256

 

Any help would be appreciated.

 

Regards

Rajat

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

Hi, @Rajat529 ;

Try this column by dax.

Output2 = 
var _maxdate= CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[Id]))
return IF([Date]=_maxdate,[Leads])

 The final show:

vyalanwumsft_0-1663660756472.png


Best Regards,
Community Support Team _ Yalan Wu
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-yalanwu-msft
Community Support
Community Support

Hi, @Rajat529 ;

Try this column by dax.

Output2 = 
var _maxdate= CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[Id]))
return IF([Date]=_maxdate,[Leads])

 The final show:

vyalanwumsft_0-1663660756472.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@Rajat529 Try:

Column Output =
  VAR __ID = [Id]
  VAR __LastDate = MAXX(FILTER('Table',[Id] = __ID),[Date])
RETURN
  MAXX(FILTER('Table',[Id] = __ID && [Date] = __LastDate),[Leads])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

This is very near to the solution but I m not getting blank() in the earlier dates rather i m getting like below

 

DateMonthNr LeadsIDSlatest_lead

Monday, September 12, 2022September56145
Monday, September 19, 2022September23145
Monday, September 26, 2022September45145
Monday, October 3, 2022October21145
Monday, October 10, 2022October22145
Monday, October 17, 2022October23145
Thursday, November 24, 2022November45145
Monday, September 12, 2022September56256
Monday, September 19, 2022September23256
Monday, September 26, 2022September45256
Monday, October 3, 2022October21256
Monday, October 10, 2022October22256
Monday, October 17, 2022October23256
Thursday, November 24, 2022November56256

 

see latest_lead in the last column i m getting through your dax.

 

can you please update?

 

Thanks

Rajat

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.

Top Solution Authors
Top Kudoed Authors