Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Need help in formulating a column

Hello Experts,
I am new to powerbi and would appreciate your help.
I have a sample data as below:

IDDate
115-09-19
120-10-19
210-08-19
223-11-19
329-11-19
315-12-19
307-01-20

 

Expectation: I want to add a column which would contain only True or False values based on the below logic
                     For a given ID, the row with max date should display True else False

The expected table should look like:

IDDateT/F
115-09-19F
120-10-19T
210-08-19F
223-11-19T
329-11-19F
315-12-19F
307-01-20T


Looking forward to response.
Thanks

  • Hi Anonymous ,

     

    The formula az38  created is a measure.

     

    If you want a calculated column, you can do like this:

    Column = 
    VAR x = 
    CALCULATE(
        MAX([Date]),
        ALLEXCEPT(
            Sheet1,
            Sheet1[ID]
        )
    )
    RETURN
    IF(
        [Date] = x,
        "T", "F"
    )

     

     

6 Replies

  • v-lionel-msft's avatar
    v-lionel-msft
    Community Support

    Hi Anonymous ,

     

    The formula az38  created is a measure.

     

    If you want a calculated column, you can do like this:

    Column = 
    VAR x = 
    CALCULATE(
        MAX([Date]),
        ALLEXCEPT(
            Sheet1,
            Sheet1[ID]
        )
    )
    RETURN
    IF(
        [Date] = x,
        "T", "F"
    )

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks a lot to you both v-lionel-msft  and az38  for your help and replies.
      Feel happy to be part of this community.
      Keep up the good work guys!

  • az38's avatar
    az38
    Community Champion

    Hi Anonymous 

    try a measure

    Measure = 
    var _maxDate = CALCULATE(MAX(Table[Date]), ALLEXCEPT(Table, Table[ID]))
    RETURN
    IF(SELECTEDVALUE(Table[Date]) = _maxDate, TRUE(), FALSE() )
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks az38 for the quick response but the below command is giving me an error after RETURN

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you @az38 for the quick response, but the following command is giving me an error after RETURN

      • az38's avatar
        az38
        Community Champion

        Anonymous 

        what the text of error?