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
RicLup
Helper III
Helper III

LASTDATE Value LOOKUPVALUE

Hi guys!

I would like help me with my Dax Formula. I need to bring the LASTDATE Value in the Exchange Type Table toward another Table called Total.

I´ve been used  LOOKUPVALUE to compare the distinct parameters But my problem is that only bring when the Date is the same in the two tables and I need the LASTDATE Value found.

My Formula:

 

EXR MXN = 
LOOKUPVALUE (
    'Exchange Type'[Value Exchange Type],
    'Exchange Type'[ExchangeType.De], Total[Desc Exchange],
    'Exchange Type'[Date Exchange Type].[Date], LASTDATE (
        (
            FILTER (
                ALL ( 'Exchange Type'[Date Exchange Type] ),
                'Exchange Type'[Date Exchange Type] <= Total[Date]
            )
        )
    )
)

 

 

My table Exchange Type

Exchange Type.PNG

 

My table Total and the results empty:

 

Total.PNG

 

I can´t bring the value when the Date in Exchange Type is in the past respect for the DATE in Total Table.

 

Regards and thanks!

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @RicLup 

Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. A screen cap doesn't allow people to readily copy the data and run a quick test and thus decreases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here. Or, ideally, share the pbix (beware of confidential data).

Try this for the calculated column in the Total table:

EXR MXN =
VAR LastDate_ =
    CALCULATE (
        MIN ( 'Exchange Type'[Date Exchange Type] ),
        FILTER (
            ALL ( 'Exchange Type' ),
            'Exchange Type'[Desc Exchange Type] = Total[Desc Exchange]
                && 'Exchange Type'[Date Exchange Type] <= 'Total'[Date]
        )
    )
RETURN
    CALCULATE (
        DISTINCT ( 'Exchange Type'[Value Exchange Type] ),
        FILTER (
            ALL ( 'Exchange Type' ),
            'Exchange Type'[Desc Exchange Type] = Total[Desc Exchange]
                && 'Exchange Type'[Date Exchange Type] = LastDate_
        )
    )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

 

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @RicLup 

Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. A screen cap doesn't allow people to readily copy the data and run a quick test and thus decreases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here. Or, ideally, share the pbix (beware of confidential data).

Try this for the calculated column in the Total table:

EXR MXN =
VAR LastDate_ =
    CALCULATE (
        MIN ( 'Exchange Type'[Date Exchange Type] ),
        FILTER (
            ALL ( 'Exchange Type' ),
            'Exchange Type'[Desc Exchange Type] = Total[Desc Exchange]
                && 'Exchange Type'[Date Exchange Type] <= 'Total'[Date]
        )
    )
RETURN
    CALCULATE (
        DISTINCT ( 'Exchange Type'[Value Exchange Type] ),
        FILTER (
            ALL ( 'Exchange Type' ),
            'Exchange Type'[Desc Exchange Type] = Total[Desc Exchange]
                && 'Exchange Type'[Date Exchange Type] = LastDate_
        )
    )

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

 

Thanks a lot @AlB, the formula works perfect and Im gonna take your tips for the next posts.

 

Regards!

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.