Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I have vitual tables each one shows the expected sales dates for a particular project. One is based on the budgeted date and the other is based on the current dates. I want to compare the 1st current date to the 1st budget date and then the 2nd current date to the 2nd budget date, and so on. I created a meausre that indexes them 1,2,3,n [CENumber] with the thoguht that I could match them up and calcualte the difference in dates.
I cant seem to figure out how to relate or lookup the date values between these tables in order to calcualte the difference and then sum the total delay. Any help would be appreciated
Below is the code that gets me each of the tables for a particular project and year but I am stuck on how to relate or look up dates between them to calculate the difference.
Solved! Go to Solution.
Hi @mgrayTCB ,
I think you're ignoring the parentheses of Table.Sort function. Please try this:
= Table.AddIndexColumn( Table.Sort( [Group], { {"Date", Order.Ascending} } ), "Index", 1, 1, Int64.Type )
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@mgrayTCB , when you have the common date and project taking a diff measure at a visual level between measures from two tables for the displayed column
If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Thank you for thinking about this. Here is a bit more detail. I have a budget table(DevRevenueBudget) and a Current table (DevRevenue). Budget was frozen at the begining of the year. Each project has a series of sales events they were sechedule on cetrain dates at budget time but now have updated (current dates). I want to calculate the delay. See model and expected result.
Hi @mgrayTCB ,
Not sure if I understand correctly. I create the following example data. =
Then add index to pre group.
#"Grouped Rows" = Table.Group(#"Changed Type", {"ProjectID"}, {{"Group", each _, type table [Date=nullable date, ProjectID=nullable number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn(Table.Sort([Group],{{"Date", Order.Ascending}}), "Index", 1, 1, Int64.Type)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Date", "ProjectID", "Index"}, {"Date", "ProjectID", "Index"})
Create calaulated table [Index] and create relationship with table [DevRevenueBudget] and [DevRevenue].
Index =
DISTINCT (
UNION ( VALUES ( DevRevenue[Index] ), VALUES ( DevRevenueBudget[Index] ) )
)
Then create the measure.
Measure =
DATEDIFF (
SELECTEDVALUE ( DevRevenue[Date] ),
SELECTEDVALUE ( DevRevenueBudget[Date] ),
DAY
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I am working though this and trying to add the index to the revenue table. I got the grouping step to work but cant get the index step to work. I keep getting this error:
This is the M code I am trying to add in the Add Custom column step.
Table.AddIndexColumn(Table.Sort[Group],{{"DateActOrEst",Order.Ascending}},"Index",1,1,Int64.Type)
This was taken right from your example other than the name of the date field.
Hi @mgrayTCB ,
I think you're ignoring the parentheses of Table.Sort function. Please try this:
= Table.AddIndexColumn( Table.Sort( [Group], { {"Date", Order.Ascending} } ), "Index", 1, 1, Int64.Type )
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is very helpful. I will work through this solution with my data and let you know if I have any questions
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |