Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Based on month selection need to get amounts

Hi Team, I have Month year as an slicer and Total amounts in My Table. so when user click on the Month  i need to to get filter the data on below way. Can you please provide me the measures to achievce this.

1. Prior month total sales(Consider If user select May month, i need to show may month sales)

2. Last 12 month total sales(Last 12 months data)

3. Last month total sales.(April Month Sales)

4. Next month sales.(Consider if user selects an Feb then i need to show march sales)

1 Reply

  • Hello Anonymous , If I understood your requirement correctly below measure will help you in achieving your requirement. But please check with column names and also create a month number column in your table to use this. 

    Total Sales = 
    Var SelectedMonth = Month(SelectedValue(Date))
    Var CMSales = Calculate(Sum(Sales),Filter(Table,Table[Month]=SelectedMonth))
    Var PTMSales = Calculate(Sum(sales),DateAdd(Dates,SelectedMonth-12,Month))
    Var LMSales = Calculate(Sum(sales),Filter(Table,Table[Month] = SelectedMonth-1))
    Var NMSales = Calculate(Sum(sales),DateAdd(Dates,SelectedMonth+1,Month))
    Return
    CMSales+PTMSales+LMSales+NMSales

     

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