Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi Cummunity
Could please help me with rolling 3 values whitout dates, for example
Operation = value1/value2
Thanks a lot
Solved! Go to Solution.
Hi @alfredorhz
Please refer to attached file
3rolling =
VAR CurrentIndex = Data[Index]
VAR OnAndBeforeTable = FILTER ( Data, Data[Index] <= CurrentIndex )
VAR Last3Table = TOPN ( 3, OnAndBeforeTable, [Index] )
RETURN
IF (
COUNTROWS ( Last3Table ) = 3,
DIVIDE (
SUMX ( Last3Table, [value1] ),
SUMX ( Last3Table, [value2] )
)
)
Hi,
This calculated column formula works
=if(CALCULATE(countrows(Data),FILTER(Data,Data[Index]>=EARLIER(Data[Index])-2&&Data[Index]<=EARLIER(Data[Index])))<=2,BLANK(),divide(CALCULATE(SUM(Data[value]),FILTER(Data,Data[Index]>=EARLIER(Data[Index])-2&&Data[Index]<=EARLIER(Data[Index]))),CALCULATE(SUM(Data[value2]),FILTER(Data,Data[Index]>=EARLIER(Data[Index])-2&&Data[Index]<=EARLIER(Data[Index])))))
Hope this helps.
Thank yoy @Ashish_Mathur
I don´t know why the index values in the EARLY function send this error, 'parameter is not the correct type'. any clue?
Hi,
In the Query Editor, ensure that the Data type of the Index column is whole number.
Hi @alfredorhz
Please refer to attached file
3rolling =
VAR CurrentIndex = Data[Index]
VAR OnAndBeforeTable = FILTER ( Data, Data[Index] <= CurrentIndex )
VAR Last3Table = TOPN ( 3, OnAndBeforeTable, [Index] )
RETURN
IF (
COUNTROWS ( Last3Table ) = 3,
DIVIDE (
SUMX ( Last3Table, [value1] ),
SUMX ( Last3Table, [value2] )
)
)
HI @tamerj1
Thanks for your support
May be I forgot write somenthing, Colum2 values is a calculate column, and I try to use the SELECTVALUE function but didn´t works, send me "the expresion refers to multiple colums" I don´t know if was usin the wrong funcion....
Hi @alfredorhz
I just noticed your reply. Why do you need to use SELECTEDVALUE? It is irrelevant that Value2 is a calculated column, the code I proposed should work either ways. Did you try it? If so, what results did you get?
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.