Forum Discussion
krishnavzm
3 years agoFrequent Visitor
How to display total cost value based on two date values
Hi, I'm new to Power BI. Trying to create a report based on the data available from 2020- 2023. Please find the beow sample data. Item code Dispatch date Estimated Cost Arrival Date ...
- 3 years ago
Hi, krishnavzm
You can try the following methods. Divide your sample data into 2 tables.
Table1:
Table2:
New Table:
Date = CALENDAR(MIN('Table 1'[Dispatch Date]),MAX('Table 2'[Arrival Date]))Column:
Year = YEAR([Date])Month = MONTH([Date])Measure:
Total Actual cost / Monthly = CALCULATE ( SUM ( 'Table 2'[Actual Cost] ), FILTER ( ALL ( 'Date' ), [Year] = SELECTEDVALUE ( 'Date'[Year] ) && [Month] = SELECTEDVALUE ( 'Date'[Month] ) ) )Total Estimated cost / Monthly = CALCULATE ( SUM ( 'Table 1'[Estimated Cost] ), FILTER ( ALL ( 'Date' ), [Year] = SELECTEDVALUE ( 'Date'[Year] ) && [Month] = SELECTEDVALUE ( 'Date'[Month] ) ) )Result:
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-zhangti
Community Support
3 years agoHi, krishnavzm
You can try the following methods. Divide your sample data into 2 tables.
Table1:
Table2:
New Table:
Date = CALENDAR(MIN('Table 1'[Dispatch Date]),MAX('Table 2'[Arrival Date]))
Column:
Year = YEAR([Date])Month = MONTH([Date])
Measure:
Total Actual cost / Monthly =
CALCULATE (
SUM ( 'Table 2'[Actual Cost] ),
FILTER (
ALL ( 'Date' ),
[Year] = SELECTEDVALUE ( 'Date'[Year] )
&& [Month] = SELECTEDVALUE ( 'Date'[Month] )
)
)
Total Estimated cost / Monthly =
CALCULATE (
SUM ( 'Table 1'[Estimated Cost] ),
FILTER (
ALL ( 'Date' ),
[Year] = SELECTEDVALUE ( 'Date'[Year] )
&& [Month] = SELECTEDVALUE ( 'Date'[Month] )
)
)
Result:
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
krishnavzm
3 years agoFrequent Visitor
Thanks for the help. I got an idea now. Will work on the actual model