Forum Discussion

Raulx_7's avatar
Raulx_7
Helper I
5 years ago
Solved

Inventory price update

Hi, I have 3 tables: - Dates  - Products  - Price    The current price is calculated using a metric, where can be specified if the value is the current or accumulated.  This measure is called: ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Raulx_7 

    According to your statement, I know your have three tables.

    - Dates 

    - Products 

    - Price 

    From your code, I think Price table should be related with Dates table, but I don't know what your data model actually looks like.

    I think your connection mode is live connection, so you couldn't build a rank column.

    I update the measure.

    NewMeasure = 
    VAR _CPrice =
        SUM ( 'Price'[Price] )
    VAR _LastMonthEnd =
        EOMONTH ( MAX ( 'Date'[Date] ), -1 )
    VAR _LastMonthStart =
        EOMONTH ( MAX ( 'Date'[Date] ), -2 ) + 1
    VAR _LMPrice =
        CALCULATE (
            SUM ( 'Price'[Price] ),
            FILTER (
                ALL ( 'Date' ),
                'Date'[Date] >= _LastMonthStart
                    && 'Date'[Date] <= _LastMonthEnd
            )
        )
    RETURN
        _CPrice - _LMPrice

    Result is as below.

    Best Regards,

    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.