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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
STimon
Frequent Visitor

Calculate booked amount and to be renewed based on contract dates

Hi,

 

I'm trying to build a measure to expand a monthly amount between dates, taking into account if its' booked or to be renewed, (that depends on the contract end date)

 

This is the table with the contract amounts and dates. I dont' care about the day of the month. I've got a contract monthly amount that can change from one month to another; that's why I calculate from monthly amount and not total amount

 

CONTRACTSTART DATEEND DATETOTAL MONTHSMONTHS BOOKED FROM ACTUAL MONTH (INCLUDED)MONTHLY AMOUNTAMOUNT BOOKEDLAST MONTH FOR CALCULATIONSAMOUNT TO BE RENEWED
AAA01/01/201730/09/202260175.000,0085.000,0001/11/202210.000,00
BBB17/11/202017/11/202236191.000,0019.000,0001/11/20220,00
CCC01/05/202130/09/2021552.500,0012.500,0001/11/202235.000,00
      116.500,00 

45.000,00

 

We already have another calendar table from 01 Jan 2021 to last contract date (17 Nov 2022). And I want to build a measure to get something like this:

 

 2021 2022 
 BOOKEDTO BE RENEWEDBOOKEDTO BE RENEWED
JANUARY  6.000,002.500,00
FEBRUARY  6.000,002.500,00
MARCH  6.000,002.500,00
APRIL  6.000,002.500,00
MAY8.500,00 6.000,002.500,00
JUNE8.500,00 6.000,002.500,00
JULY8.500,00 6.000,002.500,00
AUGUST8.500,00 6.000,002.500,00
SEPTEMBER8.500,00 6.000,002.500,00
OCTOBER6.000,002.500,001.000,007.500,00
NOVEMBER6.000,002.500,001.000,007.500,00
DECEMBER6.000,002.500,00  
     
 60.500,007.500,0056.000,0037.500,00

 

Can you help me? I've been looking here for some measures example but I can't get the right formula

 

Thanks!!

 

1 ACCEPTED SOLUTION
STimon
Frequent Visitor

Ok, I figured it out!

Maybe it's a bit rough 😁 but If no one find another easy solutions I'll marked it lately as solved, in case it helps anyone.

 

I created a crossjoin table (RESULT): 

RESULT = CROSSJOIN(BOOKING,SELECTCOLUMNS(CONTRACT,"CONTRACT",CONTRACT[CONTRACT],"END DATE",CONTRACT[END DATE].[Date],"MONTHLY AMOUNT",CONTRACT[MONTHLY AMOUNT]))
 
And inside this table two calculated columns:
BOOKED = IF(or(RESULT[END DATE]>RESULT[END OF MONTH],ENDOFMONTH(RESULT[END DATE].[Date])=RESULT[END OF MONTH]),RESULT[MONTHLY AMOUNT],0)
 
TO BE RENEWED = 
TO BE RENEWED = IF(ENDOFMONTH(RESULT[END DATE].[Date])<RESULT[END OF MONTH],RESULT[MONTHLY AMOUNT],0)
 
And from this table a Matrix visual and filter works nicely:
RESULTMATRIX.png
The final pbix: https://we.tl/t-EHJgR7LxSO 
 
 
 
 
 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Not clear enough to solve. The first table does not represent correctly the problem since you say that the monthly amount for a contract can change; data should always be representative of the problem at hand and this is not reflected in any way in the table, as much as I can judge.

 

I would kindly suggest reading this first before posting: https://community.powerbi.com/t5/DAX-Commands-and-Tips/How-to-Get-Your-Question-Answered-Quickly/td-...

 

To get a solution you'll have to put a bit more effort into the explanation, I'm afraid.

Hi,
The change of the monthly amount doesn't really matter, I probably expressed myself wrong. If was just trying to explain that another solution I've found that comes from a total value doesn't work for me or I don't know how to make it work in my scenary (https://community.powerbi.com/t5/Desktop/How-to-spread-value-between-two-dates/m-p/914942 )

I already have managed to built a table only with the last date of the month. So I've got two tables, one is called Contracts, with all the monthly amounts, contract start date and end date, and another one is called Bookings, with last date of month. I have a PBIX file with this examples:

 

https://we.tl/t-u8OTZqM8RD 

 

CONTRACT:

CONTRACT START DATE END DATE MONTHLY AMOUNT
AAA 01/01/2017 30/09/2022 5.000,00
BBB 17/11/2020 17/11/2022 1.000,00
CCC 01/05/2021 30/09/2021 2.500,00

BOOKINGS (goes like this, with all last end day of the month bettween today and last contract end date):

 

MONTH
31/05/2021
30/06/2021
31/07/2021

What I trying to get is to spread the monthly amount between all of "MONTHS" in table "BOOKINGS" only when the Contract End Date < MONTHS

Something like this is the result I need to get:

MONTH BOKEED TO BE RENEWED
31/05/2021 8.500,00 0,00
30/06/2021 8.500,00 0,00
31/07/2021 8.500,00 0,00
31/08/2021 8.500,00 0,00
30/09/2021 8.500,00 0,00
31/10/2021 6.000,00 2.500,00
30/11/2021 6.000,00 2.500,00
31/12/2021 6.000,00 2.500,00
31/01/2022 6.000,00 2.500,00
28/02/2022 6.000,00 2.500,00
31/03/2022 6.000,00 2.500,00
30/04/2022 6.000,00 2.500,00
31/05/2022 6.000,00 2.500,00
30/06/2022 6.000,00 2.500,00
31/07/2022 6.000,00 2.500,00
31/08/2022 6.000,00 2.500,00
30/09/2022 6.000,00 2.500,00
31/10/2022 1.000,00 7.500,00
30/11/2022 1.000,00 7.500,00

And of course I'll need to filter also for each contract, for example if i filter contract CCC, the result should be like this:

MONTH BOKEED TO BE RENEWED
31/05/2021 2.500,00 0,00
30/06/2021 2.500,00 0,00
31/07/2021 2.500,00 0,00
31/08/2021 2.500,00 0,00
30/09/2021 2.500,00 0,00
31/10/2021 0,00 2.500,00
30/11/2021 0,00 2.500,00
31/12/2021 0,00 2.500,00
31/01/2022 0,00 2.500,00
28/02/2022 0,00 2.500,00
31/03/2022 0,00 2.500,00
30/04/2022 0,00 2.500,00
31/05/2022 0,00 2.500,00
30/06/2022 0,00 2.500,00
31/07/2022 0,00 2.500,00
31/08/2022 0,00 2.500,00
30/09/2022 0,00 2.500,00
31/10/2022 0,00 2.500,00
30/11/2022 0,00 2.500,00

STimon
Frequent Visitor

Ok, I figured it out!

Maybe it's a bit rough 😁 but If no one find another easy solutions I'll marked it lately as solved, in case it helps anyone.

 

I created a crossjoin table (RESULT): 

RESULT = CROSSJOIN(BOOKING,SELECTCOLUMNS(CONTRACT,"CONTRACT",CONTRACT[CONTRACT],"END DATE",CONTRACT[END DATE].[Date],"MONTHLY AMOUNT",CONTRACT[MONTHLY AMOUNT]))
 
And inside this table two calculated columns:
BOOKED = IF(or(RESULT[END DATE]>RESULT[END OF MONTH],ENDOFMONTH(RESULT[END DATE].[Date])=RESULT[END OF MONTH]),RESULT[MONTHLY AMOUNT],0)
 
TO BE RENEWED = 
TO BE RENEWED = IF(ENDOFMONTH(RESULT[END DATE].[Date])<RESULT[END OF MONTH],RESULT[MONTHLY AMOUNT],0)
 
And from this table a Matrix visual and filter works nicely:
RESULTMATRIX.png
The final pbix: https://we.tl/t-EHJgR7LxSO 
 
 
 
 
 

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.

Top Solution Authors