Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Display elements from a selected date (between start and end date)

Hi PowerBI Community,

 

I don't find a way to display information according to a selected date. Here is my problem:

 

I have a set of data that looks like this:

 

I would like to sum up the estimated volumes for a specific year. Let's say that I select multiple years using a dropdown list:

 

I selected 2025 and 2026, so I would like to display the result of the following calculation: 2*411,613 (because both 2025 and 2026 are both between 2021 and 2026) + 1*63,442 (because only 2025 is between 2020 and 2025) + ...

 

I hope that my issue is not too complex to understand, I tried to explain the simplest way.

I am really looking forward to reading your solutions!

 

Thank you very much!

Clemman

  • Hi, Anonymous 

     

    You can try the following methods.

    Measure =
    VAR _table =
        ADDCOLUMNS (
            'Year',
            "Value",
                SUMX (FILTER ('Table',
                        [Start date] <= EARLIER ( 'Year'[Year] )
                            && [End date] >= EARLIER ( 'Year'[Year] ) ),
                    [Estimated volume] ) )
    RETURN
        SUMX ( _table, [Value] )

    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.

2 Replies

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, Anonymous 

     

    You can try the following methods.

    Measure =
    VAR _table =
        ADDCOLUMNS (
            'Year',
            "Value",
                SUMX (FILTER ('Table',
                        [Start date] <= EARLIER ( 'Year'[Year] )
                            && [End date] >= EARLIER ( 'Year'[Year] ) ),
                    [Estimated volume] ) )
    RETURN
        SUMX ( _table, [Value] )

    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.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

    This is exactly what I wanted to do!

     

    Thank you very much v-zhangti !