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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Flo_19
Frequent Visitor

Pro rata based on duration according to month

Hello everybody,

 

For my project, in want to represent a value on a pro rata basis, according to its duration. Let me explain :

If a task lasts 1.5 month like this : 

Flo_19_0-1682088135668.png

I want to add +0.67 (1/1,5 = 0.67) in January and +0.33 (0.5/1.5 = 0.33) in Feburary 

For doing this, I have the following columns : 

Flo_19_1-1682088279755.png

ARRET : count of the value I want to show

DATE DEBUT : Start date of the task

DATE FIN : End date of the task

DU : Duration of the task

Mois : Beginning month of the task

 

I want to know how to proceed to reach my goal. 

 

At the end of the work, I want to have something like this : 

Flo_19_2-1682088778146.png

 

I want to make one measure for each color (they are not calculated from the same column).

 

Thank you for your help.

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

What do the colours on the column chart represent?  Also, data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello @Ashish_Mathur,

The colours are the type of my value, let me show you a sample of my dataset.

YEARSTART DATEEND DATEDURATIONFIRST TYPESECOND TYPE
202201/01/202215/02/202245A/
202315/03/202318/05/202364BD
202507/01/202506/02/202530A/
202124/08/202112/12/2021110CD
202509/03/202527/03/202518B/
202712/04/202716/05/202734A/
202413/03/202420/10/2024221A/
202312/12/202316/01/202435C/
202109/06/202116/08/202168B/
202230/10/202213/12/202244B/
202427/02/202404/04/202437B/
202407/01/202415/03/202468C/
202517/07/202520/08/202534C/
202630/01/202622/07/2026173A/
202310/11/202304/02/202486C/
202303/05/202325/05/202322B/
202704/08/202715/09/202742C/
202227/06/202230/07/202233AD
202221/02/202213/05/202281CD
202324/03/202310/07/2023108B/
202409/09/202412/10/202433B/
202617/11/202613/12/202626B/
202402/01/202416/05/2024135A/
202312/07/202315/02/2024218A/
202318/05/202330/07/202373B/
202215/04/202218/05/202233C/
202513/04/202522/07/2025100CD
202217/08/202222/09/202236A/
202515/09/202519/10/202534AD

 

I have for informations all these columns, the value I want to show on my visual corresponds to stops on site. I would like to know the proportion of the duration of my stop over the month, compared to the total duration of this stop. 

If we take the first line of my sample, the stop begin 01/01/2022 and stop 15/02/2022. We have 30 days of stop in January and 15 days in February. So I want to have 30/45 for January (duration on January / Total duration) and 15/45 for February.

After I want to make the sum of all these results for each month, for having the pro rata basis occupation of my stops per month. 

All stops have one or two type : 

 - Column FIRST TYPE is A,B or C 

 - Columns SECOND TYPE is D or nothing

If a stop has in FIRST TYPE "A" and in SECOND TYPE "D", I want to count my stop for A and for D (one stop for A and one stop for D, I need to dissociate both)

Flo_19_0-1682583667514.png

At the end, I want to have this kind of visual

(The values of the columns are wrong here, I made my visual without the prorata basis. I we take the first line of my sample, begin 01/01/2022 and stop 15/02/2022, it will count 1 for January and 1 for february, where I want 0.67 for January and 0.33 for February).

Thank you for your interest.

 

I still do not understand your requirement.  To make things simple, based on the sample table that you have shared, show the expected result in a simple Table format.  Once that is done, we can create any visual we want. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello @Ashish_Mathur ,

 

I finally find the solution for my problem !

Thanks you a lot for your proposition of helping me, but it's not necessary anymore. 

 

Sincerely.

 

Florian.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Hello @lbendlin,

Here is a sample of my dataset.

YEARSTART DATEEND DATEDURATIONFIRST TYPESECOND TYPE
202201/01/202215/02/202245A/
202315/03/202318/05/202364BD
202507/01/202506/02/202530A/
202124/08/202112/12/2021110CD
202509/03/202527/03/202518B/
202712/04/202716/05/202734A/
202413/03/202420/10/2024221A/
202312/12/202316/01/202435C/
202109/06/202116/08/202168B/
202230/10/202213/12/202244B/
202427/02/202404/04/202437B/
202407/01/202415/03/202468C/
202517/07/202520/08/202534C/
202630/01/202622/07/2026173A/
202310/11/202304/02/202486C/
202303/05/202325/05/202322B/
202704/08/202715/09/202742C/
202227/06/202230/07/202233AD
202221/02/202213/05/202281CD
202324/03/202310/07/2023108B/
202409/09/202412/10/202433B/
202617/11/202613/12/202626B/
202402/01/202416/05/2024135A/
202312/07/202315/02/2024218A/
202318/05/202330/07/202373B/
202215/04/202218/05/202233C/
202513/04/202522/07/2025100CD
202217/08/202222/09/202236A/
202515/09/202519/10/202534AD

 

I have for informations all these columns, the value I want to show on my visual corresponds to stops on site. I would like to know the proportion of the duration of my stop over the month, compared to the total duration of this stop. 

If we take the first line of my sample, the stop begin 01/01/2022 and stop 15/02/2022. We have 30 days of stop in January and 15 days in February. So I want to have 30/45 for January (duration on January / Total duration) and 15/45 for February.

After I want to make the sum of all these results for each month, for having the pro rata basis occupation of my stops per month. 

All stops have one or two type : 

 - Column FIRST TYPE is A,B or C 

 - Columns SECOND TYPE is D or nothing

If a stop has in FIRST TYPE "A" and in SECOND TYPE "D", I want to count my stop for A and for D (one stop for A and one stop for D, I need to dissociate both)

Flo_19_1-1682584447757.png

 

At the end, I want to have this kind of visual

(The values of the columns are wrong here, I made my visual without the prorata basis. I we take the first line of my sample, begin 01/01/2022 and stop 15/02/2022, it will count 1 for January and 1 for february, where I want 0.67 for January and 0.33 for February).

Thank you for your interest.

First step is to correct your source data to bring it into a usable form

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bVNbEoMwCLyL350JkJf5bO0tnN7/GgWFhKgz+gGzbBZY9n0BDPwREC2vBXMAsuDNf1h+r/1IR0lHwawBsgUf/r8HBqryZE5BUZ488VAKsEoahYcCkgXb4Gn6lpRSdcFn6KEASdJVeIrqqbPmqKVJeCAgWPD2PKeEqDxomK1jRE/pmotrYOiJRn/MMCopTRhphYye1Z8NpAnTZ5h0F/GuBxlT+3xA9eQJw3pOniIY0oIy986a0XoXPfTQe3SrpnzZu2Jsp1U1Nwu2qfdiIxFx1Xvs3Duhsx7awzR5Q/wzfGg8Fz1NJST1GNznzDPEPp++rzLzkN+FeezmnyGh384F488lPmuW0tR7Xy+9Dz+nvndyJhjzEW+sViqY9nzLzUqx6XzsTpnn9wc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"START DATE" = _t, #"END DATE" = _t, #"FIRST TYPE" = _t, #"SECOND TYPE" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"START DATE", "END DATE"}, "Attribute", "Value"),
    #"Removed Other Columns" = Table.SelectColumns(#"Unpivoted Other Columns",{"START DATE", "END DATE", "Value"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each ([Value] <> "/"))
in
    #"Filtered Rows"

Then you can expand the dates between Start and End

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bVNbEoMwCLyL350JkJf5bO0tnN7/GgWFhKgz+gGzbBZY9n0BDPwREC2vBXMAsuDNf1h+r/1IR0lHwawBsgUf/r8HBqryZE5BUZ488VAKsEoahYcCkgXb4Gn6lpRSdcFn6KEASdJVeIrqqbPmqKVJeCAgWPD2PKeEqDxomK1jRE/pmotrYOiJRn/MMCopTRhphYye1Z8NpAnTZ5h0F/GuBxlT+3xA9eQJw3pOniIY0oIy986a0XoXPfTQe3SrpnzZu2Jsp1U1Nwu2qfdiIxFx1Xvs3Duhsx7awzR5Q/wzfGg8Fz1NJST1GNznzDPEPp++rzLzkN+FeezmnyGh384F488lPmuW0tR7Xy+9Dz+nvndyJhjzEW+sViqY9nzLzUqx6XzsTpnn9wc=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"START DATE" = _t, #"END DATE" = _t, #"FIRST TYPE" = _t, #"SECOND TYPE" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"START DATE", "END DATE"}, "Attribute", "Value"),
    #"Removed Other Columns" = Table.SelectColumns(#"Unpivoted Other Columns",{"START DATE", "END DATE", "Value"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each ([Value] <> "/")),
    #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"START DATE", type date}, {"END DATE", type date}},"en-GB"),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each {Number.From([START DATE])..Number.From([END DATE])}),
    #"Expanded Date" = Table.ExpandListColumn(#"Added Custom", "Date"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Date",{{"Date", type date}})
in
    #"Changed Type1"

 

, and finally you can add a Calendar table to your data model.  With these prerequisites the chart creation is easy.

 

lbendlin_0-1682612738173.pnglbendlin_1-1682612835516.png

see attached

 

 

Hello @lbendlin,

 

I found the way to achieve my goal, in parts thanks to your proposition. 

I inspired a lot my work around your way to transform the file in power querry. 

After, I needed to obtain one row per Stop per month and calculate the prorata for each row.

Thanks you again for your help !

Hi @lbendlin, Thanks you for your very complete response !

I will check your solution in more details tomorrow. And see if it respond to my problem.

 

Thanks you again ! 

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.