cancel
Showing results for
Search instead for
Did you mean:
Helper I

## Help with a measure in DAX.

This one is a little tricky & has me pulling my hair out.

TestMeasure =
var currentMonth = SELECTEDVALUE(MyTable[Month])
var currentYear = SELECTEDVALUE(MyTable[ValYear])
var currentQuarter = SELECTEDVALUE(MyTable[ValQuarter])
var IDSelected = SELECTEDVALUE(MyTable[ID])

var nextMon = currentMonth + 1

var valInt = CALCULATE(SUM(MyTable[Value]),MyTable[ValQuarter] = currentQuarter, MyTable[Month] = nextMon, MyTable[ValYear] = currentYear,MyTable[ID] = IDSelected)
var valInt1 = CALCULATE(([Ratio Factor]),MyTable[ValQuarter] = currentQuarter, MyTable[Month] = nextMon, MyTable[ValYear] = currentYear,MyTable[ID] = IDSelected)
var valInt2 = CALCULATE(([Current Month Proj]),MyTable[ValQuarter] = currentQuarter, MyTable[Month] = nextMon, MyTable[ValYear] = currentYear,MyTable[ID] = IDSelected)

var valNextTemp = (valInt / valInt1) + valInt2
var valNext = (valNextTemp / [Ratio Factor]) + [Current Month Proj]

return valNext

The measure that I have created above works fine for the first pass. (i.e. when my month selection is 1)

However, for the next pass, I need to have the starting point (valNextTemp) i.e. the numerator to be the result of the calculation in my previous iteration.
i.e. for my month selection 2, the valInt should be equal to the valNext value (when the month selection was 1).

e.g. in my first iteration of my valNext value was 1359916, in my next iteration the value of valNextTemp should be 1359916 & not the starting point value.

My months are in a column & go right upto 240 (i.e. 2 years of data).

3 REPLIES 3
Super User I
can i ask what your objective is, what are you trying to do?

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Helper I

@vanessafvg ,pls see below what I am trying to do :

I cannot share my dataset but lemme show you some sample calcs -

so as we see below, my A4 cell will be A5 (lets say there is no value) so it will be (zero divided by Col1 = 0) + Col7 = Col7

Now, the starting point for calculating the value in A3 cell will be the value in A4 (i.e. the numerator will be the answer of the calculation in cell A4) and so on i.e for A2 the starting point will be the value in the A3 cell (i.e. result of A4 /Table Col1 + Table Col7 )

Hope this helps..

A1                                                              A2                                           A3                                                       A4

 =A2/ Table Col1 + Table Col7 =A3 / Table Col1 + Table Col7 =A4 /Table Col1 + Table Col7 =A5/Table Col1 + Table Col7
Super User I
if you can provide some dummy data that would be useful.

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

## Helpful resources

Announcements

#### Happy New Year from Power BI

This is a must watch for a message from Power BI!

#### Check it Out!

Click here to read more about the December 2020 Updates!

#### Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

#### Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors