Forum Discussion
Anonymous
4 years agoNot applicable
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...
- 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 🙂
Anonymous
4 years agoNot applicable
The relationship is date i managed the relationship as the date
| Table 1 | Table 2 | |||||||||
| date | cost | sales | cost per day | date | sales | cost per day | ||||
| 10/5/2021 | "cost is fixed at 10 because <2022" | 70 | "=" cost *sales per day | 30/4/2021 | 70 | "=" table1[cost] *sales per day | ||||
| 10/20/2021 | 40 | 9/29/2021 | 67 | |||||||
| 1/5/2022 | 3 | 21 | 1/5/2022 | 50 | ||||||
| 9/4/2022 | 6 | 68 | 9/4/2022 | 190 | ||||||
| 9/5/2022 | 7 | 55 | 9/5/2022 | 90 | ||||||
| 9/6/2022 | 3 | 65 | 9/6/2022 | 55 | ||||||
| 9/7/2022 | 4 | 89 | 9/7/2022 | 120 |
SpartaBI
Community Champion
4 years agoAnonymous what is the granulrity of the relationship? 1:1 , 1:m? In case it's 1:m who is the 1 and who is the mant? in case it's 1:1 why don't you just join the tables?
- Anonymous4 years agoNot applicable
im not gonna lie to you, i have no idea what you meant, i am new to dax abd stuff
- SpartaBI4 years ago
Community Champion
Anonymous No worries. I will pm you
- Anonymous4 years agoNot applicable
very much appreciated