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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.