Forum Discussion

josfebo's avatar
josfebo
Frequent Visitor
4 years ago
Solved

Compare price previous non continuous date

Hello to all of you!   After reading many forums and posts related to this topic, I need your help.   I am building a table to compare the price of a product of the current date against the price...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi josfebo ,

    Please update the formula of your measure [Previous Day Price 1] as below and check whether it can return the correct result...

    Previous Day Price 1 =
    VAR current_date =
        SELECTEDVALUE ( d_Calendario[Fecha] )
    VAR curresta =
        SELECTEDVALUE ( delivery_menu[Restaurante] )
    VAR curitem =
        SELECTEDVALUE ( delivery_menu[xxcolumname] )
    VAR previous_visibleDate =
        CALCULATE (
            MAX ( delivery_menu[Fecha] ),
            FILTER (
                ALLSELECTED ( delivery_menu ),
                delivery_menu[Restaurante] = curresta
                    && delivery_menu[xxcolumname] = curitem
                    && delivery_menu[Fecha] < current_date
                    && [Precio] <> BLANK ()
            )
        )
    VAR previous_visibleDatePrice =
        CALCULATE (
            [Precio],
            FILTER (
                ALLSELECTED ( delivery_menu ),
                delivery_menu[Restaurante] = curresta
                    && delivery_menu[xxcolumname] = curitem
                    && delivery_menu[Fecha] = previous_visibleDate
            )
        )
    RETURN
        previous_visibleDatePrice

    In addition, you can refer the following links to get it.

    Power Query method:

    Get previous row in Power Query - EXPLAINED

    DAX method:

    Power BI DAX Getting the Value of Previous Non-NULL Row

    Calculate previous row using DAX

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

    How to upload PBI in Community

    Best Regards