Forum Discussion

stefani_vileva's avatar
stefani_vileva
Resolver II
4 years ago
Solved

Date filtered calculation

Hello everyone,   I have the following situation, I have Date table, Sellings, Orders and Indicatiors table. In the sellings I have all of the sales that we have made with the total revenue for eac...
  • v-yanjiang-msft's avatar
    4 years ago

    Hi stefani_vileva ,

    I downloaded your file, because Revenue is a calculated column in your file, the value of a calculated column cann't change based on the slicer, they are only calculated when you first define them and during a dataset refresh. So always for Selected Min Date it takes the lowest value of the parametar (01.01.2022) and for the maximum (31.12.2022). Refer to this article for more information: Difference between calculated columns and measures? 

    Here's my solution.

    Create a measure.

    Measure =
    VAR curr_date_min =
        DATE ( MAX ( 'Indicators'[Year] ), MONTH ( [Selected Min Date] ), DAY ( [Selected Min Date] ) )
    VAR curr_date_max =
        DATE ( MAX ( 'Indicators'[Year] ), MONTH ( [Selected Max Date] ), DAY ( [Selected Max Date] ) )
    RETURN
        CALCULATE (
            SUM ( Sellings[Revenue] ),
            Sellings[Date] >= curr_date_min
                && Sellings[Date] <= curr_date_max
        )
    

    Get the correct result.

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.