Forum Discussion

lkcz04185's avatar
lkcz04185
New Member
2 years ago

Matrix Report - Column Difference

Hi,

working on a Power Bi matrix style report, like below.

Slicer to select two Dates (years,qts) to compare prices per product category for.

How do I write a measure to calculate deltas of the two price categories (low, high) related to the selected dates. So that, the formula dynamically reference the Dates selection to filter respective product prices.

Can somebody help, please?

 

 

7 Replies

  • sjoerdvn's avatar
    sjoerdvn
    Solution Sage

    Does not sound too hard, but you really need to include some samples of the tables you are using, and their relationships.

  • sjoerdvnthanks for the feeedback. Using just one table atm. There are 3 slicers configured. Date, Tower, Country.

    I need to calculate deltas between Price1 and Price2 for each product and two selectable dates at a time.

     

    DateTowerCountryCategoryProductPrice1 LowPrice1 HighPrice 2 LowPrice 2 High
    2019-11-30SecurityUSANetworkProduct 185.695.7252.6282.5
    2019-11-30SecurityUSANetworkProduct 2363.9396.71074.01170.8
    2019-11-30SecurityUSANetworkProduct 3268.1292.8791.3864.2
    2019-11-30SecurityUSANetworkProduct 43.64.010.611.8
    2019-11-30SecurityUSAApplicationProduct 54.14.612.113.6
    2019-11-30SecurityUSAApplicationProduct 61.21.33.53.8
    2019-11-30SecurityUSAApplicationProduct 7231.0257.2681.8759.1
    2019-11-30SecurityUSAApplicationProduct 8269.1298.3794.2880.4
    2020-03-31SecurityUSANetworkProduct 185.695.7252.6282.5
    2020-03-31SecurityUSANetworkProduct 2363.9396.71074.01170.8
    2020-03-31SecurityUSANetworkProduct 3268.1292.8791.3864.2
    2020-03-31SecurityUSANetworkProduct 43.64.010.611.8
    2020-03-31SecurityUSAApplicationProduct 54.14.612.113.6
    2020-03-31SecurityUSAApplicationProduct 61.21.33.53.8
    2020-03-31SecurityUSAApplicationProduct 7231.0257.2681.8759.1
    2020-03-31SecurityUSAApplicationProduct 8269.1298.3794.2880.4

     

     

  • sjoerdvn's avatar
    sjoerdvn
    Solution Sage

    so assuming the Date column has no relationship with a date dimension, I think it should be something like this:

    delta price1 =
    VAR d1 = MIN('atm'[Date])
    VAR d2 = MAX('atm'[Date])
    RETURN CALCULATE(MIN('atm'[Price1],'atm'[Date]=d2) - CALCULATE(MIN('atm'[Price1],'atm'[Date]=d1)
    • lkcz04185's avatar
      lkcz04185
      New Member

      Thank you for your reply!

      A bit confused about the parenthesis in the formula. I've tried to add some, as well.

      Either way I'm only getting this error.

      "A single value for colum 'Price1' in table 'Current' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result".

      I actually don't need a single value it should be a column with values for every row (Product).

      • sjoerdvn's avatar
        sjoerdvn
        Solution Sage

        you tried someything like this?

        delta price1 =
        VAR d1 = MIN('atm'[Date])
        VAR d2 = MAX('atm'[Date])
        RETURN CALCULATE(MIN('atm'[Price1]),'atm'[Date]=d2) - CALCULATE(MIN('atm'[Price1]),'atm'[Date]=d1)