Forum Discussion

yaman123's avatar
yaman123
Icon for Post Partisan rankPost Partisan
5 years ago
Solved

Past 12 Months Transfers

Hi all,  

 

I have the below measure but it is not producing the correct result. 

 

Measure 2 =

var x1= SELECTEDVALUE('Date'[Date].[MonthNo])

var x2=MAXX('Table',('Table'[FROM DATE].[MonthNo]))


return

IF(x2>=x1-12&&x2<=x1,1,0)
 
I would like to show all data from the chosen date and the previous 12 months. The measure is only showing me the month for last year.
 
E.g if i select Feb 2021, i would like to show all data previous 12 months. But the measure is showing me Feb 21 and Feb 20 data only. 
 
TIA 
 
Yasir
  • Hi, yaman123 

     

    It’s wrong to get the month like 'x2>=x1-12&&x2<=x1'. If you have a month slicer, and you want to filter data in table viusal, you can put the following measure in filter pane and set 1.

    measure =
    IF (
        DATEDIFF ( MAX ( 'Table'[FROM DATE] ), SELECTEDVALUE ( 'Date'[Date] ), MONTH ) <= 12,
        1,
        0
    )
    

    If it doesn’t solve your problem, please share some sample data and your desired result ,and feel free to ask me.

     

    Best Regards

    Janey Guo

     

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

4 Replies

    • yaman123's avatar
      yaman123
      Icon for Post Partisan rankPost Partisan

      Hi, 

       

      That doesnt help. 

       

      I would like to show the past 12 months of transfers

  • v-janeyg-msft's avatar
    v-janeyg-msft
    Icon for Community Support rankCommunity Support

    Hi, yaman123 

     

    It’s wrong to get the month like 'x2>=x1-12&&x2<=x1'. If you have a month slicer, and you want to filter data in table viusal, you can put the following measure in filter pane and set 1.

    measure =
    IF (
        DATEDIFF ( MAX ( 'Table'[FROM DATE] ), SELECTEDVALUE ( 'Date'[Date] ), MONTH ) <= 12,
        1,
        0
    )
    

    If it doesn’t solve your problem, please share some sample data and your desired result ,and feel free to ask me.

     

    Best Regards

    Janey Guo

     

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

    • yaman123's avatar
      yaman123
      Icon for Post Partisan rankPost Partisan

      Hi, 

       

      Thanks for that. I think that gives me what i require