Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Using IF to multiply columns according to date

Hello, i am trying to multiply 2 columns say cost and number of sales according to the date. so if date is before 2022, the cost is 10 and fixed but if the date is in 2022 or later, i calculate the g...
  • SpartaBI's avatar
    4 years ago

    Anonymous missing info about your model, but let's try (assuming you have all the columns in one table):
    In case yor need a calculate column than adjust this code to your model needs:

    Column = Table[Quantity] * IF( YEAR('Table'[Date]) < 2022, 10, Table[Cost])


    In case it's a measure go with this:

    Measure = 
    SUMX(	
        'Table',
        Table[Quantity] * IF( YEAR('Table'[Date]) < 2022, 10, Table[Cost])
    )

     
    In case it answered your question please mark this as a solution for community visibility. Appreciate Your Kudos 🙂