Hello @tt.xavier,
Thank You for posting your query onto the Forum.
In order to achieve the solution as per the given condition. Firstly, we’ll be required to remove any kind of active relationship between the “Dates” table and “Data” table, if exists any. We can convert them into in-active one’s. Below is the screenshot provided of the data model for the reference -
Now, create the two measures as provided below -
Total Value - Pro Rata =
VAR _Total_Value =
CALCULATE( SUM( Data[Value] ) ,
TREATAS( VALUES( Dates[Date] ) , Data[First Date of Each Month] ) )
VAR _No_of_Days_In_A_Month =
CALCULATE( COUNTROWS( Dates ) ,
Dates[DayOfWeekName] <> "Saturday" ,
Dates[DayOfWeekName] <> "Sunday" )
VAR _Hire_Days_In_A_Month =
CALCULATE(
VAR _Individual_Hire_Days =
FILTER( Dates ,
Dates[Date] >= SELECTEDVALUE( Data[Start Date] ) &&
Dates[Date] <= SELECTEDVALUE( Data[Finish Date] ) )
VAR _Results =
COUNTROWS( _Individual_Hire_Days )
RETURN
_Results ,
Dates[DayOfWeekName] <> "Saturday" ,
Dates[DayOfWeekName] <> "Sunday" )
VAR _Results =
DIVIDE( _Hire_Days_In_A_Month , _No_of_Days_In_A_Month , 0 ) * _Total_Value
RETURN
_Results
Total Value - Pro Rata - Totals =
VAR _Cross_Joins =
CROSSJOIN(
VALUES( Data[Description] ) ,
VALUES( Dates[Month & Year] ) )
VAR _Virtual_Table =
ADDCOLUMNS(
_Cross_Joins ,
"@Totals" ,
[Total Value - Pro Rata] )
VAR _Remove_Blanks =
FILTER( _Virtual_Table ,
NOT ISBLANK( [@Totals] ) )
VAR _Results =
SUMX( _Remove_Blanks ,
[@Totals] )
RETURN
_Results
Once these measures are created, simply put the second measure into the visuals and you’ll see the results on a pro-rata basis. Below is the screenshot of the final results provided for the reference -
I’m also attaching the working of the PBIX file for the reference purposes.
Hoping you find this useful and meets your requirements that you’ve been looking for. ![:slightly_smiling_face: :slightly_smiling_face:](https://forum.enterprisedna.co/images/emoji/apple/slightly_smiling_face.png?v=12)
Important Note: The pro-rata will apply to the “Opportunity 3” as well since the start date of that opportunity is 14th Feb, 2022.
Thanks and Warm Regards,
Harsh
Opportunity Value Over Period - Pro Rata Basis - Harsh.pbix (75.0 KB)