Forum Discussion

Rajat529's avatar
Rajat529
New Member
3 years ago
Solved

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

  • 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:


    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.

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Rajat529 Try:

    Column Output =
      VAR __ID = [Id]
      VAR __LastDate = MAXX(FILTER('Table',[Id] = __ID),[Date])
    RETURN
      MAXX(FILTER('Table',[Id] = __ID && [Date] = __LastDate),[Leads])
    • Rajat529's avatar
      Rajat529
      New Member

      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

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    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:


    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.