Forum Discussion
Have calculated IF statement based on date slicer
- Anonymous6 years ago
Hi Anonymous
Try this measure
Measure 2 =var currencyVALUE=MAX(Sales[Currency])returnIF(MIN(Sales[Date])=MIN('Date'[Date]),SELECTEDVALUE(Sales[Value 1])*CALCULATE(MAX('Currency'[FX Rate]),FILTER('Currency','Currency'[Date]=MAX('Date'[Date]) && 'Currency'[Currency]=currencyVALUE)),IF(MIN(Sales[Date])=MAX('Date'[Date]),(SELECTEDVALUE(Sales[Value 1])+SELECTEDVALUE(Sales[Value 2]))*CALCULATE(MAX('Currency'[FX Rate]),FILTER('Currency','Currency'[Date]=MAX('Date'[Date]) && 'Currency'[Currency]=currencyVALUE)),IF(MIN('Date'[Date])>MIN(Sales[Date]) &&MIN(Sales[Date]) <MAX('Date'[Date]),SELECTEDVALUE(Sales[Value 2])*CALCULATE(MAX('Currency'[FX Rate]),FILTER('Currency','Currency'[Date]=MAX('Date'[Date]) && 'Currency'[Currency]=currencyVALUE)))))Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.
Hi Anonymous Pravin,
Thank you very much for all your help. I've learned a tremendous amount from your replies!
I have tweaked the code somewhat in order to have everything working properly, as this part wasn't working properly.
IF(MIN('Date'[Date])>MIN(Sales[Date]) &&MIN(Sales[Date]) <MAX('Date'[Date])
I believe it has to do with a date format not being able to recognise the <> characters.
Please find my final code below:
Measure =
Hi Anonymous Pravin,
I still have one more question however, which is with regards to an XIRR calculation I now would like to make based on the measure that you helped build. This proves to be more difficult than I thought however. Would you mind helping me with this?
I now have the following table, of which I would like to use the XIRR calculation in order to get 1 figure which will show me the Internal Rate of Return (IRR):
| Name | Currency | Date | Value 1 | Value 2 | Measure |
| A | I | 31/03/2010 | 200 | 20 | -160 |
| A | I | 30/06/2010 | 200 | 100 | 80 |
| A | P | 30/09/2010 | 150 | 0 | 0 |
| A | O | 31/12/2010 | 150 | 20 | 20 |
| A | I | 31/03/2011 | 100 | 10 | 8 |
| A | O | 30/06/2011 | 150 | 50 | 50 |
| A | P | 30/09/2011 | 110 | 20 | 12 |
| A | I | 31/12/2011 | 120 | 20 | 16 |
| A | I | 31/03/2012 | 110 | 60 | 136 |
As the XIRR function looks as follows: XIRR(<table>, <values>, <dates>, [guess]) , it asks me to provide a column with values. I unfortunately only have the measure containing the values. If I fill this measure in in the function, I will get an error.
Please let me know if you're able to assist me with this.
Many thanks,
Stan Kamerbeek