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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Cleo5
Regular Visitor

Retrieving Value from other table based on a condition and the distinct row value

Hi there,
for most of my challenges I found solutions within this forum. However, not for this one. I'm stuck in the thinking process and need support.
I have one imported table ('MBRMIG_Status') and one calculated table ('LatestMigStatusForEachMBR) which is related to the imported table via the "Vorgangsschluessel" (Document name)

Cleo5_0-1665133815264.png

The imported table has besides the three imported columns

Cleo5_1-1665134186637.png

two other calculated columns:

MigStatusGroup = IF(SUMX(Migrationstatus, FIND(UPPER(Migrationstatus[Migrated]), UPPER(MBRMIG_Status[LatestStatus], ,0)) > 0, "Migrated", BLANK())

Instead of the Blank() there are 4 more If-conditions just with different status group wordings (besides "migrated", also "finished," "OtherStatus", ...).

LatestTransitionDate = CALCULATE(MAX(MBRMIG_Status[Transition to status last date]), ALLEXCEPT (MBRMIG_Status, MBRMIG_Status[Vorgangsschluessel]))

Telling me what was the last date something changed for the specific document ("Vorgangsschluessel).

My calculated column

Cleo5_2-1665134216542.png

was created based on having each "Vorgangsschluessel" just once:

LatestMigStatusForEachMBR = DISTINCT(SELECTCOLUMNS(MBRMIG_Status, MBRMIG_Status[Vorgangsschluessel]))

and adding again the latest date:

LatestTransDate = CALCULATE(MAX(MBRMIG_Status[Transition to status last date]), ALLEXCEPT (LatestMigStatusForEachMBR, LatestMigStatusForEachMBR[MBRMIG_Status_Vorgangsschluessel]))


Now I struggle to fetch the MigStatusGroup from my 'MBRMIG_Status'-Table specific for the document name ("Vorgangsschluessel") and where the "LatestTransDate" (calulcated table) is the same as the "Transition to status date" (imported table).

LatestStatusOnThisDate = CALCULATE(
    COUNTROWS(MBRMIG_Status),
        FILTER(MBRMIG_Status, MBRMIG_Status[LatestTransitionDate] = LatestMigStatusForEachMBR[LatestTransDate])
        ALLEXCEPT(LatestMigStatusForEachMBR, LatestMigStatusForEachMBR[MBRMIG_Status_Vorgangsschluessel])
    )

 

Solution should look like this:

Cleo5_3-1665134408342.png


Any suggestions?

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Cleo5 

 

You can try the following methods.

Sample data:

vzhangti_0-1665394786006.png

Result:

vzhangti_1-1665394819420.png

LatestTransDate = LOOKUPVALUE('Table'[LatestTransDate],'Table'[Vor],[Vor])
Column = CALCULATE(MAX('Table'[MigStatusGroup]),FILTER('Table',[Transition to status last date]=EARLIER('Table 2'[LatestTransDate])))

Refer to the attachment.

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Cleo5 

 

You can try the following methods.

Sample data:

vzhangti_0-1665394786006.png

Result:

vzhangti_1-1665394819420.png

LatestTransDate = LOOKUPVALUE('Table'[LatestTransDate],'Table'[Vor],[Vor])
Column = CALCULATE(MAX('Table'[MigStatusGroup]),FILTER('Table',[Transition to status last date]=EARLIER('Table 2'[LatestTransDate])))

Refer to the attachment.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Cleo5
Regular Visitor

Solution was found by using more arguments in Lookupvalue

LatestStatusOnThisDate = LOOKUPVALUE(MBRMIG_Status[MigStatusGroup], MBRMIG_Status[Vorgangsschluessel], LatestMigStatusForEachMBR[MBRMIG_Status_Vorgangsschluessel], MBRMIG_Status[Transition to status last date], LatestMigStatusForEachMBR[LatestTransDate])

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.