Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Rolling 12 months in table visualisation

Hi Team,

 

I have raw data like below table :- 

CaseIdNameStaffLine of ServiceViolation HistoryFine AmountDate
11ShubhamPartnerABCMatter Type A…650Jan
12ShubhamPartnerABCMatter Type A…650Feb
13ShubhamPartnerABCMatter Type A…700March
14ShubhamPartnerABCMatter Type B…0Jan
15ShubhamPartnerABCMatter Type B…0Feb
16ShubhamPartnerABCMatter Type C…500Jan
17FayazManagerPQRMatter Type A…650Jan
18FayazManagerPQRMatter Type A…650Feb
19FayazManagerPQRMatter Type A…700March
20FayazManagerPQRMatter Type B…0Jan
21FayazManagerPQRMatter Type B…0Feb
22FayazManagerPQRMatter Type C…500Jan

 

 

 

and I wanted to create rolling 12 months output like below table :- 

 

 

NameStaffLine of ServiceViolation HistoryCount of CasesTotal Amount
ShubhamPartnerABCMatter Type A…33000
   Matter Type B…20
   Matter Type C…1500
SubTotal    3500
FayazPartnerPQRMatter Type A…33000
   Matter Type B…200
   Matter Type C…1500
SubTotal    3500

 

Could you please help me on this ?

 

Thanks,

Shubham

2 Replies

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Community Support

    Hi Anonymous ,

     

    You need to have a date column to roll. We can use the following steps to meet your requirement.

     

    1. Create a date table that doesn’t contain relationship.

     

    date = 
    ADDCOLUMNS(CALENDAR("2020/1/1","2020/12/31"),"month name",FORMAT([Date],"mmm"),"month number",MONTH([Date]))

     

     

    2. Create two measures,

     

    Count = 
    var selected_ = MIN('date'[Date])
    var selected_12 = DATE(YEAR(selected_)-1,MONTH(selected_),DAY(selected_))
    return
    CALCULATE(COUNT('Table'[Violation History]),FILTER('Table','Table'[Date]<=selected_ && 'Table'[Date]>=selected_12))

     

    Total Amount = 
    var selected_ = MIN('date'[Date])
    var selected_12 = DATE(YEAR(selected_)-1,MONTH(selected_),DAY(selected_))
    return
    CALCULATE(SUM('Table'[Fine Amount]),FILTER('Table','Table'[Date]<=selected_ && 'Table'[Date]>=selected_12))

     

    3. Then we can create a matrix table,

     

     

    Turn off the stepped layout,

     

     

    And in the subtotal, we can configure it as screenshot.

     

     

    4. At last, we can add a slicer based on date table, the result like this,

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

    BTW, pbix as attached.

     

    Best regards,

     

    Community Support Team _ zhenbw

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      v-zhenbw-msft Thank you so much for your solution. It was really helpful 🙂