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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DenTOK
New Member

GROUPBY and VLOOKUP (???)

Dear The Community World, seems I can not solve my task without your help!

I have a table and I need to make grouping (firts by Project, then MAX Rev.Date, then MAX Rev.Number) and afterwards return the value from another coloumn.

 

More clear in the picture bellow:

DenTOK_0-1617544798221.png

 

I didn't find a similar task in our Forum. 

Looking forward with your response!

BR Den

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @DenTOK 

Try this:

 

Latest Code = 
IF (
    HASONEVALUE ( Projects[Project] ),
    CALCULATE ( 
        SELECTEDVALUE ( Projects[CODE] ),
        GENERATE ( 
            LASTDATE ( Projects[Revision Date] ),
            LASTNONBLANK ( Projects[Revision Number], 0 )
        )
    )
)

 

The key part of the measure is GENERATE ( ... ), which finds the maximum Revision Date using LASTDATE (returning a 1x1 a table), and then finds the maximum Revision Number in the context of that date filter using LASTNONBLANK (also returning a 1x1 table). These become a combined filter, and the single value of CODE is returned with this filter applied.

 

The measure is also restricted to return blank unless a single Project is visible in the filter context.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @DenTOK 

Try this:

 

Latest Code = 
IF (
    HASONEVALUE ( Projects[Project] ),
    CALCULATE ( 
        SELECTEDVALUE ( Projects[CODE] ),
        GENERATE ( 
            LASTDATE ( Projects[Revision Date] ),
            LASTNONBLANK ( Projects[Revision Number], 0 )
        )
    )
)

 

The key part of the measure is GENERATE ( ... ), which finds the maximum Revision Date using LASTDATE (returning a 1x1 a table), and then finds the maximum Revision Number in the context of that date filter using LASTNONBLANK (also returning a 1x1 table). These become a combined filter, and the single value of CODE is returned with this filter applied.

 

The measure is also restricted to return blank unless a single Project is visible in the filter context.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

THANK YOU, @OwenAuger !

Your proposal works as it should!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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