Forum Discussion

Saes's avatar
Saes
Icon for Helper I rankHelper I
3 years ago
Solved

Identify Earliest Records

Hi all,

 

I've got a set of tenancy lettings data and I need to categorise a lettings order for each property. For example, the data I have looks like this:

 

Tenancy IDTenancy Start DateProperty IDAddress
TEN00101/04/2005PROP0011 PowerBI Street
TEN00221/06/2007PROP0011 PowerBI Street
TEN00321/10/2007PROP0011 PowerBI Street
TEN00404/08/2017PROP0022 Computer Close
TEN00523/06/2021PROP0022 Computer Close
TEN00625/10/2021PROP0022 Computer Close

 

And I need to add a calculated column that shows this:

 

Tenancy IDTenancy Start DateProperty IDAddressTenancy Letting ID
TEN00101/04/2005PROP0011 PowerBI StreetFirst Let
TEN00221/06/2007PROP0011 PowerBI StreetSecond Let
TEN00321/10/2007PROP0011 PowerBI StreetThird Let
TEN00404/08/2017PROP0022 Computer CloseFirst Let
TEN00523/06/2021PROP0022 Computer CloseSecond Let
TEN00625/10/2021PROP0022 Computer CloseThird Let

 

I've tried several combinations of DAX, but I've not been successful. Can anyone help?

 

Thanks!

 

  • Saes's avatar
    Saes
    3 years ago

    Thank you - I had to make a tweak, but it worked. The final formula I've used is here:

    Tenancy Letting Order =

        RANKX (
                FILTER (
                    ALL ( 'Lettings Data'), [Property ID] = EARLIER ( 'Lettings Data'[Property ID] ) ),
                        'Lettings Data'[Tenancy ID],
                        ,
                        ASC,
                        DENSE
            )

2 Replies

  • You could add a calculated column like

    Letting number =
    RANKX (
        ALLEXCEPT ( 'Table', 'Table'[Property ID] ),
        'Table'[Tenancy Start Date],
        ASC
    )
    • Saes's avatar
      Saes
      Icon for Helper I rankHelper I

      Thank you - I had to make a tweak, but it worked. The final formula I've used is here:

      Tenancy Letting Order =

          RANKX (
                  FILTER (
                      ALL ( 'Lettings Data'), [Property ID] = EARLIER ( 'Lettings Data'[Property ID] ) ),
                          'Lettings Data'[Tenancy ID],
                          ,
                          ASC,
                          DENSE
              )