Forum Discussion
Apply a factor to measure based on date range table
- 3 years ago
Hi pheukshorst,
Thanks for the sample numbers. I am assuming you meant that the dates in the Cost Plus Fuel table is like as shown in the screen print below instead of two January dates and two February dates for AA and BB Account Numberes respectively.
With this assumption, I have copied and pasted the rest of the sample data table you've prepared, and created the data model like shown below:
Please note that, only the Cost Plus Fuel table has a relationship with the calendar table, while Fuel Surcharge table with the duration information of the applicable surcharge does not have any relationship with the calender table. Also, I've created a dimension table for Account Number in order to avoid many-to-many relationship which creates ambiguity and confusion in the data model. I've then created many-to-one relationships for the Account Number dimension table with the fact tables.
Next, I created a dax measure expression to capture the cost plus percentage for a selected date which falls within the duration range.
Next, I've created a calculated column which wraps the measure created above with Calculate function to respect the row context of this table.
The result generated is as you have requested. Please let me know if you'd like to have the pbix file for this task.
Hi pheukshorst,
Thanks for the sample numbers. I am assuming you meant that the dates in the Cost Plus Fuel table is like as shown in the screen print below instead of two January dates and two February dates for AA and BB Account Numberes respectively.
With this assumption, I have copied and pasted the rest of the sample data table you've prepared, and created the data model like shown below:
Please note that, only the Cost Plus Fuel table has a relationship with the calendar table, while Fuel Surcharge table with the duration information of the applicable surcharge does not have any relationship with the calender table. Also, I've created a dimension table for Account Number in order to avoid many-to-many relationship which creates ambiguity and confusion in the data model. I've then created many-to-one relationships for the Account Number dimension table with the fact tables.
Next, I created a dax measure expression to capture the cost plus percentage for a selected date which falls within the duration range.
Next, I've created a calculated column which wraps the measure created above with Calculate function to respect the row context of this table.
The result generated is as you have requested. Please let me know if you'd like to have the pbix file for this task.