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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Masoud_
Frequent Visitor

Math formula across different rows

Hi all, 

I have a question about writing a DAX function to analyse different rows of data either in the same table or across other tables.

 

Untitled.jpg

I am trying to solve it but it seems harder than it looks.

 

Thanks with Regards,

1 ACCEPTED SOLUTION
davehus
Memorable Member
Memorable Member

Hi @Masoud_ ,

 

This should work for you. Add it as Calculated Column

 

Result = 
VAR V_Date = 'Table Test'[Time]
VAR V_Filter = FILTER('Table Test', [Time] > V_Date)
VAR V_NextRow = MINX(V_Filter, [Time])
Var Result = MINX(FILTER(V_Filter, [Time] = V_NextRow), [Celsius])
RETURN IF(OR(Result-'Table Test'[Celsius]<-3,Result<35),0,IF(OR(Result-'Table Test'[Celsius]>3,Result>35),1,0))

Change the table/column names to yours. If this works for you, please accept my answer. 🙂 

 

View solution in original post

2 REPLIES 2
davehus
Memorable Member
Memorable Member

Hi @Masoud_ ,

 

This should work for you. Add it as Calculated Column

 

Result = 
VAR V_Date = 'Table Test'[Time]
VAR V_Filter = FILTER('Table Test', [Time] > V_Date)
VAR V_NextRow = MINX(V_Filter, [Time])
Var Result = MINX(FILTER(V_Filter, [Time] = V_NextRow), [Celsius])
RETURN IF(OR(Result-'Table Test'[Celsius]<-3,Result<35),0,IF(OR(Result-'Table Test'[Celsius]>3,Result>35),1,0))

Change the table/column names to yours. If this works for you, please accept my answer. 🙂 

 

Hi @davehus,

 

Thank you for your answer.

 

It worked perfectly. Also, please introduce me to if you know any excellent sources for learning DAX coding, like working with variables and defining functions.

 

Kind Regards,

Masoud

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.