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
wlknsn
Helper I
Helper I

Calculating moving average in column (not measure) and repeating last non blank over timeframes.

Hi,

 

I currently have the following measure to calculate 2 moving averages:
- one on all gains

- another on all losses.

 

The averages are moving over the last 14 periodes within a timeframe (timestamps are ranked per timeframe), and timeframes can be hours, days, ... yet always having a respective timeframe. The following measure works, but I believe given it's pretty static, it should be calculated in a column instead of measure. Is this possible?

 

RSI = 

VAR 
	GainCalc = abs(CALCULATE (
    AVERAGEx(AllCandleData, [Gain]),
    filter(ALLEXCEPT ( AllCandleData,AllCandleData[Symbol],AllCandleData[Exchange],AllCandleData[Interval] ),
    AllCandleData[Rank] > (MAX(AllCandleData[Rank]) - 14 )
        && AllCandleData[Rank] <= MAX(AllCandleData[Rank])
)
    )
)
VAR 
	LossCalc = abs(CALCULATE (
    AVERAGEx(AllCandleData,[Loss]),
    filter(ALLEXCEPT ( AllCandleData,AllCandleData[Symbol],AllCandleData[Exchange],AllCandleData[Interval] ),
    AllCandleData[Rank] > (MAX(AllCandleData[Rank]) - 14 )
        && AllCandleData[Rank] <= MAX(AllCandleData[Rank])
)
    )
)

RETURN

if(LossCalc=0 , 100 , 100-(100/(1+DIVIDE(
	GainCalc,LossCalc,BLANK()))))

Unfortunately, the result should be repeated on all timeframes. Similar to last non blank. Check below for screenshot. Can anyone help me out making this work on a measure, or convert this into a calculated column?

 

repeatrsi.png

4 REPLIES 4
wlknsn
Helper I
Helper I

I don't mind making a measure or calculated column by timeframe ...

HI @wlknsn,

 

Can you please share some sample data for test?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Of course, link to some sample data where the RSI is calculated using the measure mentionned above. Again, if we can have this is a calculated column, performance would probably seriously enhanced, but not a must.

 

https://wetransfer.com/downloads/7f59fcbf232bd6e98cc53c1ad19c28fa20180814123130/73362c11c9e8ea78b551...

 

Detail

detail.jpg

 

Summary

summary.jpg

Hi @wlknsn,

 

Due to policy I can't download sample file from shared link , can you please upload it to onedrive or google drive?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.