Forum Discussion

PC2022's avatar
PC2022
Helper III
2 years ago
Solved

Weighted average within a certain date range

I calculated weighted average of the cost using "Quick measure" in Power BI:   I need to calculate weighted average within a six month date range (for example, if the bid dates of the project...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi PC2022 ,

    You can create a measure as below to get it:

    Weighted Average 6 Months =
    CALCULATE (
        SUMX (
            FILTER (
                'Test Full Pay Items',
                'Test Full Pay Items'[Bid Date] >= DATE ( 2023, 5, 1 )
                    && 'Test Full Pay Items'[Bid Date] <= DATE ( 2023, 10, 1 )
            ),
            'Test Full Pay Items'[Highest Bid] * 'Test Full Pay Items'[Qty]
        )
            / SUMX (
                FILTER (
                    'Test Full Pay Items',
                    'Test Full Pay Items'[Bid Date] >= DATE ( 2023, 5, 1 )
                        && 'Test Full Pay Items'[Bid Date] <= DATE ( 2023, 10, 1 )
                ),
                'Test Full Pay Items'[Qty]
            )
    )

    If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format and your visual settings. It would be helpful to find out the solution. You can refer the following link to share the required info:

    How to provide sample data in the Power BI Forum

     

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards