The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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
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
Solved! Go to Solution.
@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 was doing something incorrectly. Your solution worked perfectly. Thank you so much! 🙂
@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
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
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
18 | |
18 | |
16 | |
14 | |
12 |
User | Count |
---|---|
36 | |
35 | |
19 | |
18 | |
18 |