Forum Discussion

krishnavzm's avatar
krishnavzm
Frequent Visitor
3 years ago
Solved

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   ...
  • v-zhangti's avatar
    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.