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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
felipesaw
Frequent Visitor

Returns next value

Good morning, I need a formula that does:

Total-Bonus

if this is equal to 0, returns the bonus value. 

If this is different than zero then returns the next bonus value where this subtraction is equal to zero.

 

And a formula that does the same subtraction but returns the date instead of the bonus value.

 

TOTALBONUSDATE
5309/09/2022
5210/09/2022
5411/09/2022
5512/09/2022
2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@felipesaw Maybe:

 

Measure =
  VAR __Date = MAX('Table'[DATE])
  VAR __T = MAX('Table'[TOTAL])
  VAR __B = MAX('Table'[BONUS])
  VAR __R = __T - __B
  VAR __Table = ADDCOLUMNS(ALL('Table'),"__R",[TOTAL] - [BONUS])
RETURN
  IF(__R = 0, __B, VAR __D = MINX(FILTER(__Table,[__R] = 0 && [DATE]> __Date),[DATE]) RETURN MAXX(FILTER(__Table,[DATE] = __D),[BONUS])

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

Hi friend, the measure almost worked perfectly, I ended up not making it clear, but I need it to bring the first value.

 

TOTAL BONUS DATE

5309/09/2022
5210/09/2022
5411/09/2022
5512/09/2022
6513/09/2022
5514/09/2022

 

In the table above for example, I have the date 9/14 that bonus=total, but before it came the date 9/12. So I need you to return the bonus amount of the 9/12 that came first.

 

I tried to fix the first measure, but withou sucess.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.