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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
BJankic
Helper II
Helper II

Calculate Contract Renewed Amount in Second Column

Hi,

 

I'm trying to calculate renewed amount in second column (renewed value). This is original data information

 

account_idaccount_nameservice_contract namecontract_stageservice_contract_valuerenewed valueservice_contract_start_dateservice_contract_end_date
1account_name_1service_contract name_1closed_won$2,000.00 1/1/20221/1/2023
1account_name_1service_contract name_2closed_won$3,000.00 1/1/20231/1/2024
2account_name_2service_contract name_3closed_won$4,000.00 1/1/20221/1/2023
2account_name_2service_contract name_4closed_won$5,000.00 1/1/20231/1/2024
3account_name_3service_contract name_5closed_won$6,000.00 1/1/20221/1/2023
3account_name_3service_contract name_6closed_won$7,000.00 1/1/20231/1/2024
4account_name_4service_contract name_7closed_won$8,000.00 1/1/20221/1/2023
4account_name_4service_contract name_8closed_won$9,000.00 1/1/20231/1/2024

 

This is the desired outcome : 

 

account_idaccount_nameservice_contract namecontract_stageservice_contract_valuerenewed valueservice_contract_start_dateservice_contract_end_date
1account_name_1service_contract name_1closed_won $                           2,000.00 $           3,000.001/1/20221/1/2023
1account_name_1service_contract name_2closed_won $                           3,000.00 1/1/20231/1/2024
2account_name_2service_contract name_3closed_won $                           4,000.00 $           5,000.001/1/20221/1/2023
2account_name_2service_contract name_4closed_won $                           5,000.00 1/1/20231/1/2024
3account_name_3service_contract name_5closed_won $                           6,000.00 $           7,000.001/1/20221/1/2023
3account_name_3service_contract name_6closed_won $                           7,000.00 1/1/20231/1/2024
4account_name_4service_contract name_7closed_won $                           8,000.00 $           9,000.001/1/20221/1/2023
4account_name_4service_contract name_8closed_won $                           9,000.00 1/1/20231/1/2024

 

Your help is much appreciated,

 

Thank you,

 

Bojan

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@BJankic Try something like:

Column = 
  VAR __AccountID = [account_id]
  VAR __Start = [service_contract_start]
  VAR __Next = MINX(FILTER(ALL('Table'),[account_id] = __AccountID && [service_contract_start] > __Start),[service_contract_start])
  VAR __Value = MINX(FILTER(ALL('Table'), [account_id] = __AccountID && [service_contract_start] = __Next), [service_contract_value]
RETURN
  __Value


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...

View solution in original post

8 REPLIES 8
BJankic
Helper II
Helper II

Thank you, @Greg_Deckler !

Greg_Deckler
Community Champion
Community Champion

@BJankic Try something like:

Column = 
  VAR __AccountID = [account_id]
  VAR __Start = [service_contract_start]
  VAR __Next = MINX(FILTER(ALL('Table'),[account_id] = __AccountID && [service_contract_start] > __Start),[service_contract_start])
  VAR __Value = MINX(FILTER(ALL('Table'), [account_id] = __AccountID && [service_contract_start] = __Next), [service_contract_value]
RETURN
  __Value


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...

Hi @Greg_Deckler ,

 

I have a situation for this calculation that is not cathing the renewal value.

 

This one is okay :

 

Screenshot_1.jpg

 

These are not, probably because of the start date : 

Screenshot_2.jpg

Screenshot_3.jpg

 

Any chance you can update the formula?

 

Thank you.

 

Bojan

@BJankic Is that scenario in the sample data?



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 It is not. Do you want me to send you new sample?

@BJankic Yes please!



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 here it is sir.

 

Original : 

 

account_idaccount_nameservice_contract namecontract_stageservice_contract_valuerenewed valueservice_contract_start_dateservice_contract_end_date
1account_name_1service_contract name_1closed_won$2,000.00 1/1/20221/1/2023
1account_name_1service_contract name_2closed_won$3,000.00 1/1/20231/1/2024
2account_name_2service_contract name_3closed_won$4,000.00 1/1/20221/1/2023
2account_name_2service_contract name_4closed_won$5,000.00 1/1/20231/1/2024
3account_name_3service_contract name_5closed_won$6,000.00 1/1/20221/1/2023
3account_name_3service_contract name_6closed_won$7,000.00 1/1/20231/1/2024
4account_name_4service_contract name_7closed_won$8,000.00 1/1/20221/1/2023
4account_name_4service_contract name_8closed_won$9,000.00 1/1/20231/1/2024
5account_name_5service_contract name_9closed_won$560,150.00 1/2/20221/1/2023
5account_name_5service_contract name_10closed_won$582,120.00 1/20/20231/19/2024
6account_name_6service_contract name_11closed_won$140,000.00 1/2/20221/1/2023
6account_name_6service_contract name_12closed_won$145,530.00 1/20/20231/19/2024

 

Desired outcome : 

account_idaccount_nameservice_contract namecontract_stage service_contract_value  renewed value service_contract_start_dateservice_contract_end_date
1account_name_1service_contract name_1closed_won  $                           2,000.00   $           3,000.00 1/1/20221/1/2023
1account_name_1service_contract name_2closed_won  $                           3,000.00  1/1/20231/1/2024
2account_name_2service_contract name_3closed_won  $                           4,000.00   $           5,000.00 1/1/20221/1/2023
2account_name_2service_contract name_4closed_won  $                           5,000.00  1/1/20231/1/2024
3account_name_3service_contract name_5closed_won  $                           6,000.00   $           7,000.00 1/1/20221/1/2023
3account_name_3service_contract name_6closed_won  $                           7,000.00  1/1/20231/1/2024
4account_name_4service_contract name_7closed_won  $                           8,000.00   $           9,000.00 1/1/20221/1/2023
4account_name_4service_contract name_8closed_won  $                           9,000.00  1/1/20231/1/2024
5account_name_5service_contract name_9closed_won $                       560,150.00 $      582,120.001/2/20221/1/2023
5account_name_5service_contract name_10closed_won $                       582,120.00 1/20/20231/19/2024
6account_name_6service_contract name_11closed_won $                       140,000.00 $      145,530.001/2/20221/1/2023
6account_name_6service_contract name_12closed_won $                       145,530.00 1/20/20231/19/2024

@Greg_Deckler Did you manage to solve it, is there an issue with the dataset?

 

Thank you.

 

Bojan

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors