Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hdavidson
Helper I
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
vanessafvg
Super User
Super User

can i ask what your objective is, what are you trying to do?




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




@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

if you can provide some dummy data that would be useful.




If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.