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
Alvarom1
Helper I
Helper I

Distribute Revenue by periods having start date and end date

Hi,

 

I have a table like this

 

 
ContractCustomer Contract Value Start DateEnd Date
1a              150.00016/10/201815/01/2019
2b           1.000.00011/11/201831/03/2019
3c              360.00016/11/201816/04/2019
4d              450.00020/10/201831/01/2019
5a           1.500.00016/01/201927/04/2019
6b              150.00001/04/201918/05/2019
Total Contract Value           3.610.000  
 

 

And I want to be able to get a table like this (Group revenue by month...)

 

Customer10-1811-1812-1801-1902-1903-1904-1905-19Customer total
a        24.725,27        49.450,55        51.098,90      247.497,55      415.841,58      460.396,04      400.990,10                     -             1.650.000,00
b                        -        135.714,29      221.428,57      221.428,57      200.000,00      221.428,57         92.553,19      57.446,81           1.150.000,00
c                        -          33.377,48        73.907,28        73.907,28        66.754,97        73.907,28         38.145,70                     -                360.000,00
d        48.058,25      131.067,96      135.436,89      135.436,89                        -                          -                          -                       -                450.000,00
Month Total        72.783,53      349.610,28      481.871,65      678.270,30      682.596,55      755.731,90      531.688,99      57.446,81           3.610.000,00

 

Can you help me to do this?

 

I have not beenable to figure it ou with the existing related posts

 

Thanks

 

Alvaro

 

1 ACCEPTED SOLUTION

@Alvarom1 

Please find the solution attached. I do not want to use crossjoin. But seems like the one I created without cross join is not working. Measure 2 is the correct one.

Now there is a difference. That is because I included both the start and end dates to get daily value. So change the daily value as per need.

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

See if Open Tickets helps. It was designed to do something similar. https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364#M147

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg

 

I am afraid I am not getting it.

 

any chance that you can help me with my data?

 

Thanks

 

Alvaro

Let me take a look. Why is it that everyone that posts date related questions has the month and day in the wrong order? 😉


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi again,

 

looking here and there I came across this solutions that it seems to work. What do you think?

 

Monthly Value =
VAR Startdate = VALUE(SELECTEDVALUE(datos[Start Date]))
VAR Enddate = VALUE(SELECTEDVALUE(datos[End Date]))
VAR MinDate = VALUE(MIN(Calendario[Date]))
VAR MaxDate = VALUE(MAX(Calendario[Date]))
VAR DaysperContract = DATEDIFF(Startdate;Enddate;DAY)
VAR ContractValue = SUM(datos[Contract Value])

RETURN
IF(and(Startdate<MinDate;Enddate>MinDate);
(MIN(Enddate;MaxDate)-MinDate+1)*(ContractValue/DaysperContract);
IF(AND(AND(Startdate>MinDate;Startdate<MaxDate);Enddate>MinDate);
(MIN(Enddate;MaxDate)-Startdate)*(ContractValue/DaysperContract);
BLANK()))

@Alvarom1 

Please find the solution attached. I do not want to use crossjoin. But seems like the one I created without cross join is not working. Measure 2 is the correct one.

Now there is a difference. That is because I included both the start and end dates to get daily value. So change the daily value as per need.

it works!

fantastic

Thanks a lot

Alvaro

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.