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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
andra2
Helper I
Helper I

Amount calculation

Hello, 

 

I want to calculate for each candidate which is the amount only for the first 8 months of contract, no matter if he has only one or more placements. For instance, I have this sample of data for which I will expect to receive the below desired result:

Candidate IDPlacementAmountStart DateEnd DateCommentsDesired Result
x1100001/1/202010/31/2020no new placement, more than 8 months8000 - for this case, we need to calculate only 8 months from the amount
y24001/1/20203/31/2020 current placement less than 8 months 400 - placement 1, for this case we take into consideration the entire amount as 8 months did not passed and is the first placement
y2120007/1/202012/31/2020second placement, reaches 8 months with the previous placement800 - 2nd placement, we need to take into consideration only 4 months from this placement  as we had in the first placement 4 months
z34001/1/20203/31/2020 current placement less than 8 months 400 - placement 1, for this case we take into consideration the entire amount as 8 months did not passed and is the first placement
z35007/1/20209/30/2020second placement less than 8 months500 - 2nd placement, we need to take into consideration the entire amount as in the placement we have only 3 months of contract and the overall 8 months are not yet fulfilled 
z3100001/1/20225/31/2022thrid placement, fulfills the 8 months400 - 3rd placement, we need to calculate the amount only for the remaining months: 2 months =  8 months total months - 3 from the first placement - 3 from the second placement
Candidate x8000
Candidate y1200
Candidate z13000

 

Can you, please, help me with the calculations I need to deploy for it?

 

Many thanks!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@andra2 , We need the following columns

 

Months  = datediff([Start Date], [End Date], Month)+1

 

Monthly Amount = [Amount]/Months

 

Previous Month = sumx(Filter(Table,[Candidate ID] =earlier([Candidate ID]) && [Start Date] < earlier([Start Date] )) ,[Months])

 

Month to be added = Switch( True() ,

coalesce([Previous Month],0) >=8 , 0 ,

coalesce([Previous Month],0)=0 &&  [Month] <= 8 , [Month] ,

coalesce([Previous Month],0)=0 &&  [Month] >= 8 , 8 ,

[Previous Month] +[Month]<=8 && [Month] <= 8, [Month] ,

8-[Previous Month]

)

 

New Amount = [Month to be added] * [Monthly Amount]

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@andra2 , We need the following columns

 

Months  = datediff([Start Date], [End Date], Month)+1

 

Monthly Amount = [Amount]/Months

 

Previous Month = sumx(Filter(Table,[Candidate ID] =earlier([Candidate ID]) && [Start Date] < earlier([Start Date] )) ,[Months])

 

Month to be added = Switch( True() ,

coalesce([Previous Month],0) >=8 , 0 ,

coalesce([Previous Month],0)=0 &&  [Month] <= 8 , [Month] ,

coalesce([Previous Month],0)=0 &&  [Month] >= 8 , 8 ,

[Previous Month] +[Month]<=8 && [Month] <= 8, [Month] ,

8-[Previous Month]

)

 

New Amount = [Month to be added] * [Monthly Amount]

Thank you very much, it worked 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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