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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Ethanhunt123
Helper IV
Helper IV

LINESTX with slicer

Hello, 

 

I am trying to calculate trends using slope and intercept 

 

I am using the following DAX, which is functioning well. However, the issue arises when I have a slicer on the order date. I want the dataset for the query below to also get filtered for that date range when a user applies a start and end date filter on the order date slicer

Revenue trend = VAR line =

LINESTX (
ALL('Sales order line fact'[Order date] ),
[Total revenue trend],
'Sales order line fact'[Order date]
)
VAR slope = SELECTCOLUMNS ( line, [Slope1] )
VAR intercept = SELECTCOLUMNS ( line, [Intercept] )
VAR x = SELECTEDVALUE ( 'Sales order line fact'[Order date] )
VAR y = x * slope + intercept
RETURN y

1 ACCEPTED SOLUTION
BeaBF
Super User
Super User

@Ethanhunt123 Hi! Try with:

Revenue trend =
VAR line =
LINESTX (
ALLSELECTED('Sales order line fact'[Order date]), -- This respects the slicer
[Total revenue trend],
'Sales order line fact'[Order date]
)
VAR slope = SELECTCOLUMNS(line, [Slope1])
VAR intercept = SELECTCOLUMNS(line, [Intercept])
VAR x = SELECTEDVALUE('Sales order line fact'[Order date])
VAR y = x * slope + intercept
RETURN y

 

BBF

View solution in original post

4 REPLIES 4
Ethanhunt123
Helper IV
Helper IV

I was doing something incorrectly. Your solution worked perfectly. Thank you so much!  🙂 

 

BeaBF
Super User
Super User

@Ethanhunt123 Hi! Try with:

Revenue trend =
VAR line =
LINESTX (
ALLSELECTED('Sales order line fact'[Order date]), -- This respects the slicer
[Total revenue trend],
'Sales order line fact'[Order date]
)
VAR slope = SELECTCOLUMNS(line, [Slope1])
VAR intercept = SELECTCOLUMNS(line, [Intercept])
VAR x = SELECTEDVALUE('Sales order line fact'[Order date])
VAR y = x * slope + intercept
RETURN y

 

BBF

I have tried this but I don't think so this is working see below 

 

Data without the filter on date 

 

Ethanhunt123_0-1725523081733.png

Data with the filter on the date  - From Jan 1 till Sept

Values are the same as above. My assumption is if I am changing dataset then values should also get change

Ethanhunt123_1-1725523145454.png

 

@Ethanhunt123 Can you share the pbix?

 

BBF

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.