Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Calculation in DAX measure returing all the rows.

Hi Everyone,

 

I created a measure using below query. Logic wise it is correct but the only thing I am facing right now is that It is returning all the rows from the table. What I observe is I am getting this output because in Var R1 and R2 I am doing some calculation. As you can see below i am adding 1 and also multiplying it with 10. This is applying to each row in the table. Can someone please let me know how should I write R1 and R2.

 

I also have a date slicer in the report page. where I am selecting only 1 date.

 

IndexBaseValue =
Var Mindate = CALCULATE(MIN(IndexFundNAV[Date]),ALL(IndexFundNAV[Date]))
Var Maxdate = CALCULATE(MAX(IndexFundNAV[Date]))
Var Currentdate = IF(Maxdate<Mindate,Mindate,Maxdate)
Var Diffdays = DATEDIFF(Mindate,Currentdate,DAY)
Var R1 = CALCULATE(10*(1+[RITD%]))
Var R2 = CALCULATE((10*(1+[RITD%]))^(Diffdays/365))

Var Result = if (Diffdays<365,R1,R2)

Return
Result

 

Example for desired output:

Date             IndexName IndexBaseValue

28-Sep-19     ABC             8.9

 

Currently getting:

Date             IndexName IndexBaseValue

28-Sep-19     ABC             10

28-Sep-19     ABC             10

28-Sep-19     ABC             10

28-Sep-19     ABC             8.9

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2 Replies