Forum Discussion

faiznazri's avatar
faiznazri
Regular Visitor
2 years ago
Solved

Get all previous year data (December) and current data based on slicer Year-Month selection

Sample Data 

Hi everyone, appreciate if you can help me to create a bar chart that can show all December previous year sales and current date sales (based on Slicer Year-Month selection). Thanks!

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi faiznazri ,

     

    I don't have access to the data source you provided, but I did a simple test with reference to the following formula:

    M_ =
    VAR table_ =
        FILTER ( 'Date', 'Date'[Slicer] = SELECTEDVALUE ( 'Date'[Slicer] ) )
    VAR col_ =
        SELECTCOLUMNS ( table_, "col", [Date] )
    VAR sel_ =
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[Date] IN col_ || TODAY () = 'Table'[Date] )
        )
    RETURN
        sel_
    

     

    Best Regards,
    Adamk Kong

     

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

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi faiznazri ,

     

    I don't have access to the data source you provided, but I did a simple test with reference to the following formula:

    M_ =
    VAR table_ =
        FILTER ( 'Date', 'Date'[Slicer] = SELECTEDVALUE ( 'Date'[Slicer] ) )
    VAR col_ =
        SELECTCOLUMNS ( table_, "col", [Date] )
    VAR sel_ =
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[Date] IN col_ || TODAY () = 'Table'[Date] )
        )
    RETURN
        sel_
    

     

    Best Regards,
    Adamk Kong

     

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