Forum Discussion

Lanceometer's avatar
Lanceometer
Helper I
1 year ago
Solved

Visual Calculation using FIRST()

Hi Folks,   I have data for some suppliers and prices for a material: Supplier   Date   NetPrice SUP1   28.02.2024   20,66 SUP1   29.02.2024   20,66 SUP2   01.03.2024   ...
  • ValtteriN's avatar
    1 year ago

    Hi,

    As seen in the visual calculation table supplier appears twice in your filter context. Because of this it is easier not to use visual calculations in this case, since calculating first date for a specific supplier will be challenging. With normal dax you can e.g. create something like this:

    first net price division =
    var _s = SELECTEDVALUE('Table (47)'[Supplier])
      VAR _firstDate = CALCULATE(MIN('Table (47)'[Date]),ALL('Table (47)'[Date]),'Table (47)'[Supplier]=_s)
      RETURN
      DIVIDE([Average of NetPrice],
    CALCULATE(
    [Average of NetPrice],ALL('Table (47)'[Date]),'Table (47)'[Date]=_firstDate))

     

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/