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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ausrine
Frequent Visitor

Does Lookup fit here?

Hello all,
I have this problem and hoping to get your help here. I'm working with few tables, which include [Locations] (key thing is PLACE-REF), [TENANCY] (TENANT-REF) and joint between these [TENANCY PLACE] (which has both of key columns - place-ref and tenant-ref). As you can imagine, every location has a few different tenancies over the time, hence [TENANCY PLACE] table looks like:

PLACE-REF           TENANT-REF           START-DATE               END-DATE
a                       1                     x1                      z1
a                       2                     x2                      z2
b                       3                     x3                      z3

and so on. Now, my goal is to find which of these locations were let for the very first time and which tenant was the first one. For that I have a table with PLACE-REF and MIN(START-DATE) (I made this on SQL). Once I got this table, I'm not sure how to attach correct TENANT-REF. I tried to do that with lookupvalue() but I'm not sure which values to include. I'm quite new to power bi so I hope there's not big of a problem.

Thanks!

Ausrine

1 ACCEPTED SOLUTION
Eric_Zhang
Microsoft Employee
Microsoft Employee


@ausrine wrote:

Hello all,
I have this problem and hoping to get your help here. I'm working with few tables, which include [Locations] (key thing is PLACE-REF), [TENANCY] (TENANT-REF) and joint between these [TENANCY PLACE] (which has both of key columns - place-ref and tenant-ref). As you can imagine, every location has a few different tenancies over the time, hence [TENANCY PLACE] table looks like:

PLACE-REF           TENANT-REF           START-DATE               END-DATE
a                       1                     x1                      z1
a                       2                     x2                      z2
b                       3                     x3                      z3

and so on. Now, my goal is to find which of these locations were let for the very first time and which tenant was the first one. For that I have a table with PLACE-REF and MIN(START-DATE) (I made this on SQL). Once I got this table, I'm not sure how to attach correct TENANT-REF. I tried to do that with lookupvalue() but I'm not sure which values to include. I'm quite new to power bi so I hope there's not big of a problem.

Thanks!

Ausrine


@ausrine

To find out the locations were let for the first time and the tenancy record, you could create a calculated table using below DAX. See more details in the attached pbix file.

Table 2 =
FILTER (
    ADDCOLUMNS (
        'Table',
        "tenancy times"COUNTROWS (
            FILTER ( 'Table', EARLIER ( 'Table'[place-ref] ) = 'Table'[place-ref] )
        )
    ),
    [tenancy times] = 1
)

 

Capture.PNG

 

View solution in original post

2 REPLIES 2
Eric_Zhang
Microsoft Employee
Microsoft Employee


@ausrine wrote:

Hello all,
I have this problem and hoping to get your help here. I'm working with few tables, which include [Locations] (key thing is PLACE-REF), [TENANCY] (TENANT-REF) and joint between these [TENANCY PLACE] (which has both of key columns - place-ref and tenant-ref). As you can imagine, every location has a few different tenancies over the time, hence [TENANCY PLACE] table looks like:

PLACE-REF           TENANT-REF           START-DATE               END-DATE
a                       1                     x1                      z1
a                       2                     x2                      z2
b                       3                     x3                      z3

and so on. Now, my goal is to find which of these locations were let for the very first time and which tenant was the first one. For that I have a table with PLACE-REF and MIN(START-DATE) (I made this on SQL). Once I got this table, I'm not sure how to attach correct TENANT-REF. I tried to do that with lookupvalue() but I'm not sure which values to include. I'm quite new to power bi so I hope there's not big of a problem.

Thanks!

Ausrine


@ausrine

To find out the locations were let for the first time and the tenancy record, you could create a calculated table using below DAX. See more details in the attached pbix file.

Table 2 =
FILTER (
    ADDCOLUMNS (
        'Table',
        "tenancy times"COUNTROWS (
            FILTER ( 'Table', EARLIER ( 'Table'[place-ref] ) = 'Table'[place-ref] )
        )
    ),
    [tenancy times] = 1
)

 

Capture.PNG

 

Thank you @Eric_Zhang! Works perfectly.

Helpful resources

Announcements
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.