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
gjloureiro
Frequent Visitor

Compare value between two dates

I need two compare two value between two date.

I have a list with customers, product, price and sell date, and i need to know when the price by customer was readjusted.

 

Capture2.JPG

3 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

Hi @gjloureiro

 

Try these MEASURES

 

Actual Price =
CALCULATE (
    VALUES ( TableName[PRICE] ),
    FILTER (
        ALLEXCEPT ( TableName, TableName[CLIENT] ),
        TableName[DATE] = MAX ( TableName[DATE] )
    )
)
Date of Actual Price =
CALCULATE (
    LASTDATE ( TableName[DATE] ),
    ALLEXCEPT ( TableName, TableName[CLIENT] )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

@gjloureiro

 

Following MEASURES for the previous/last DATE and VALUE

 

lastdate =
VAR last_price = [Actual Price]
RETURN
    CALCULATE (
        MAX ( TableName[DATE] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[CLIENT] ),
            TableName[Actual Price] <> last_price
        )
    )

 

lastvalue =
VAR priordate = [LastDate]
RETURN
    CALCULATE (
        VALUES ( TableName[PRICE] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[CLIENT] ),
            TableName[DATE] = priordate
        )
    )

Regards
Zubair

Please try my custom visuals

View solution in original post

v-shex-msft
Community Support
Community Support

Hi @gjloureiro,

 

You can try to use below table formula to get the analysed table.

 

Original table:

8.PNG

Formula:

Table = 
ADDCOLUMNS (
    SUMMARIZE (
        'Sample',
        [CLIENT],
        [ITEM],
        "Min", MIN ( 'Sample'[PRICE] ),
        "Max", MAX ( 'Sample'[PRICE] )
    ),
    "Last Min Price Date", MAXX (
        FILTER (
            'Sample',
            [CLIENT] = EARLIER ( [CLIENT] )
                && [ITEM] = EARLIER ( [ITEM] )
                && [PRICE] = EARLIER ( [Min] )
        ),
        [DATE]
    ),
    "Last Max Price Date", MAXX (
        FILTER (
            'Sample',
            [CLIENT] = EARLIER ( [CLIENT] )
                && [ITEM] = EARLIER ( [ITEM] )
                && [PRICE] = EARLIER ( [Max] )
        ),
        [DATE]
    )
)

 

 7.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @gjloureiro,

 

You can try to use below table formula to get the analysed table.

 

Original table:

8.PNG

Formula:

Table = 
ADDCOLUMNS (
    SUMMARIZE (
        'Sample',
        [CLIENT],
        [ITEM],
        "Min", MIN ( 'Sample'[PRICE] ),
        "Max", MAX ( 'Sample'[PRICE] )
    ),
    "Last Min Price Date", MAXX (
        FILTER (
            'Sample',
            [CLIENT] = EARLIER ( [CLIENT] )
                && [ITEM] = EARLIER ( [ITEM] )
                && [PRICE] = EARLIER ( [Min] )
        ),
        [DATE]
    ),
    "Last Max Price Date", MAXX (
        FILTER (
            'Sample',
            [CLIENT] = EARLIER ( [CLIENT] )
                && [ITEM] = EARLIER ( [ITEM] )
                && [PRICE] = EARLIER ( [Max] )
        ),
        [DATE]
    )
)

 

 7.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi @gjloureiro,

 

You may refer to my solution in this workbook.

 

Hope this helps.

 

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Zubair_Muhammad
Community Champion
Community Champion

Hi @gjloureiro

 

Try these MEASURES

 

Actual Price =
CALCULATE (
    VALUES ( TableName[PRICE] ),
    FILTER (
        ALLEXCEPT ( TableName, TableName[CLIENT] ),
        TableName[DATE] = MAX ( TableName[DATE] )
    )
)
Date of Actual Price =
CALCULATE (
    LASTDATE ( TableName[DATE] ),
    ALLEXCEPT ( TableName, TableName[CLIENT] )
)

Regards
Zubair

Please try my custom visuals

@gjloureiro

 

Following MEASURES for the previous/last DATE and VALUE

 

lastdate =
VAR last_price = [Actual Price]
RETURN
    CALCULATE (
        MAX ( TableName[DATE] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[CLIENT] ),
            TableName[Actual Price] <> last_price
        )
    )

 

lastvalue =
VAR priordate = [LastDate]
RETURN
    CALCULATE (
        VALUES ( TableName[PRICE] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[CLIENT] ),
            TableName[DATE] = priordate
        )
    )

Regards
Zubair

Please try my custom visuals

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.