Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
krishnavzm
Frequent 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  Actual Cost 
I-0017/1/20221008/1/2022200
I-0027/4/20222008/4/2022300
I-0038/23/20223009/3/2022400
I-0048/24/20224009/20/2022500
I-0059/1/20225009/9/2022600
I-0069/2/202260010/2/2022700

 

From the above table , can you help me to generate chart on monthly basis. 1.Need to Display Total Actual cost / Monthly and 2. Total Estimated cost / Monthly . End User will select Year and Month as a filter option. Both 1 and 2 should be in same chart.

 

Thank you for your help

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @krishnavzm 

 

You can try the following methods. Divide your sample data into 2 tables.

Table1:

vzhangti_0-1666771929364.png

Table2:

vzhangti_1-1666771951205.png

New Table:

Date = CALENDAR(MIN('Table 1'[Dispatch Date]),MAX('Table 2'[Arrival Date]))

Column:

Year = YEAR([Date])
Month = MONTH([Date])

vzhangti_2-1666772024033.png

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:

vzhangti_3-1666772144670.png

vzhangti_4-1666772164299.png

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.

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @krishnavzm 

 

You can try the following methods. Divide your sample data into 2 tables.

Table1:

vzhangti_0-1666771929364.png

Table2:

vzhangti_1-1666771951205.png

New Table:

Date = CALENDAR(MIN('Table 1'[Dispatch Date]),MAX('Table 2'[Arrival Date]))

Column:

Year = YEAR([Date])
Month = MONTH([Date])

vzhangti_2-1666772024033.png

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:

vzhangti_3-1666772144670.png

vzhangti_4-1666772164299.png

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.

Thanks for the help. I got an idea now. Will work on the actual model

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.