Forum Discussion
NewbeePowerBI
Advocate I
9 years agoHow to use if else with two conditions using DAX
Hi, I am new to Power BI and I have data like this in sales table. I want to create a new column Max_price_new where 0 should be replaced by the Max_price of earlier quarter. e.g. This is the in...
- Anonymous9 years ago
Try using ALLEXCEPT ( Sheet1[Article] ) instead of ALL ( Sheet1 ).
- 9 years ago
Hi NewbeePowerBI,
Please refer to below calculated columns:
Quarter Num = RIGHT(Sheet1[quarter],1) Last quarter = IF ( Sheet1[Max_prise] = 0, CALCULATE ( MAX ( Sheet1[Quarter Num] ), FILTER ( ALLEXCEPT ( Sheet1, Sheet1[article], Sheet1[year] ), Sheet1[Quarter Num] < EARLIER ( Sheet1[Quarter Num] ) ) ), Sheet1[Quarter Num] ) Max_prise New = LOOKUPVALUE ( Sheet1[Max_prise], Sheet1[article], Sheet1[article], Sheet1[year], Sheet1[year], Sheet1[Quarter Num], Sheet1[Last quarter] )
Best regards,
Yuliana Gu
NewbeePowerBI
Advocate I
9 years agoHi, Thank you for your solution.
Removing MAX from this MAX ( Sheet1[QuarterSequence] ) in your query gave me half the answer of my question.
But I also have many articles like this in the column "article". How to add article condition into query? I want each article's value to be displayed
e.g.
| article | yr&qua | quarter | Max_prise | year | Max_Price_new |
| 10026858 | 2017Qtr 2 | Qtr 2 | 0 | 2017 | 19537 |
| 10026858 | 2017Qtr 1 | Qtr 1 | 19537 | 2017 | 19537 |
| 10026858 | 2016Qtr 3 | Qtr 3 | 19537 | 2016 | 19537 |
| 10026858 | 2016Qtr 1 | Qtr 1 | 19537 | 2016 | 19537 |
| 10026777 | 2016Qtr 2 | Qtr 2 | 0 | 2016 | 10 |
| 10026777 | 2016Qtr 1 | Qtr 1 | 10 | 2016 |
Anonymous
9 years agoNot applicable
Try using ALLEXCEPT ( Sheet1[Article] ) instead of ALL ( Sheet1 ).
- NewbeePowerBI9 years ago
Advocate I
Hi Anonymous Using ALLExcept and adding condition for checking year, solved my problem.