Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I love these functions and hope to leverage them to get the slope of a best fit line over a series of data. My data table looks like this:
Table1
DateTime | Type | Reading |
Feb 3 12PM | Speed | 100 |
Feb 5 9PM | Speed | 80 |
Feb 7 8PM | Temp | 45 |
Etc.
Now I can write this DAX function to give me the slope (and other stats) of the best fit line for Speed.
SELECTCOLUMNS(LINESTX(FILTER(Table1, Table1[Type] = "Speed"), Table1[Reading], Table1[DateTime]), "Slope", [Slope1])
Okay, first of all, that returns a table with a single rown and single column, but it's still a table. How can I convert that to a scalar value without resorting to variables?
Second, and more importantly, do you see an easy way for me to get slope values for EVERY Type (Speed. Temperature, etc.) without having to hard code each one in its own measure?
Thanks.
I am a bit unsure of what you are looking for. This guide uses FIRSTNONBLANK to retrieve the value from the table returned by LINEST, to make an estimation: Multiple Linear Regression in Power BI - Ben's Blog
Hope this video helps with the concept:
Thank you. I already understand the concept. I had very specific questions about how to structure the data.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
58 | |
56 | |
56 | |
38 | |
29 |
User | Count |
---|---|
75 | |
62 | |
45 | |
40 | |
39 |