Forum Discussion

rainchong7401's avatar
rainchong7401
Icon for Helper III rankHelper III
3 years ago
Solved

Unable to Sum qty

Hi Friends,
I am having some problem which is 
When I choose multiple year.
My dax formula is not summarize up those 3 years I selected.
I need help. Is it my dax formula problem? 
Kindly provide dax formula if possible.

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  rainchong7401 ,

    I created some data:

    Here are the steps you can follow:

    1. Create calculated table.

    Table 2 =
    DISTINCT('Table'[Year])

    2. Create measure.

    PREV_QTY =
    var _select=SELECTCOLUMNS('Table 2',"year",[Year])
    return
    SUMX(FILTER('Table','Table'[Year] in _select),[Amount])

    3. Result:

     

    Best Regards,

    Liu Yang

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

2 Replies

  • rainchong7401 , Try these

     

    Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

     

    Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))

     

    Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

     

     

    The previous year in grand total will take the first date to calculate the last year.

    year behind sales might work better to give you a sum
    Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  rainchong7401 ,

    I created some data:

    Here are the steps you can follow:

    1. Create calculated table.

    Table 2 =
    DISTINCT('Table'[Year])

    2. Create measure.

    PREV_QTY =
    var _select=SELECTCOLUMNS('Table 2',"year",[Year])
    return
    SUMX(FILTER('Table','Table'[Year] in _select),[Amount])

    3. Result:

     

    Best Regards,

    Liu Yang

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