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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Anonymous
Not applicable

calculate slope where x is a date field

Good morning

 

Using the web, I have a formula to give me a slope value. However I have 2 problems and i would like your guidance on it.

 

Problem 1. I need the measure to only look at the past 90 days.

Problem 2.  The Y value is stored as a 1 or 0 to indicate when an event happens. The event can happen multiple times a day and it the count of those events which i need to form my Y value in the calculation.

 

How would I modify the measure below to address my two problems.

 
Slope =
Var AvgX = CALCULATE(AVERAGE(MyAICount[Created]),all (MyAICount))
Var AvgY = CALCULATE(AVERAGE(MyAICount[Value]),all(MyAICount))
Return Divide(SUMX(MyAICount,(MyAICount[Created]-AvgX) * (MyAICount[Value] -AvgY)),
              SUMX(MyAICount,(MyAICount[Created]-AvgX) * (MyAICount[Created] - AvgX)))
 
here is the formula i am trying to replicate
Elohelae_0-1663747365105.png

Apart from the date issue, i think my issue is that after the "average" function in the varx and var y, i need to count the number of events per day and i do not know how to.

 

I look forward to any assistance.

 

Lola

 

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Refer the following article ,and check if it is helpful:

https://www.mrexcel.com/board/threads/calculate-slope-value-in-powerbi-for-given-x-and-y-values.1173085/ 

 

 

Best Regards

Lucien

Anonymous
Not applicable

@v-luwang-msft Good morning. The formaula i used came from that site. I would appreciate help modifying the formula as I described above.

 

Lola

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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