Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Divide 2 Columns with condition

Hey,  I would like to divide on column by another (but only by specific value).  So I have a table with oil/gas prices for all Europe in EUR (column weekly price per l) on specific dates of time. ...
  • v-xiaotang's avatar
    4 years ago

    Hi Anonymous 

    Thanks for reaching out to us.

    >> So let's say Bulgaria has price for Euro-Super 96 for 1,7241 Euro on 4th on July. Conversion rate in PLN for this date is 0,21314. So my outcome would be - Euro-SUper 95 on 4th of July cost 8.120519

    please try this,

    Column = 
    var _Country="Bulgaria"
    var _WeeklyPWPI=MAXX(FILTER('Table','Table'[Country Name]=_Country && 'Table'[Prices in force on]= EARLIER('Table'[Prices in force on]) && 'Table'[Product Name]= EARLIER('Table'[Product Name])),[Weekly Price with per I])
    var _divide=DIVIDE(_WeeklyPWPI,'Table'[Euro exchange rate])
    return IF('Table'[Country Name]="Poland", _divide)

    in this column code, _WeeklyPWPI returns 1,7241

    Best Regards,

    Community Support Team _Tang

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