Forum Discussion

ANAC014's avatar
ANAC014
Frequent Visitor
7 years ago
Solved

Table visual with different filters for each column (slicer interaction involved)

Hello dear community! please I need your support.

 

I have the following table

Sales PersonAmountWeekQuarter
Anna1025Q2
Peter2025Q2
Mary3025Q2
Anna4026Q2
Peter5026Q2
Mary6026Q2
Anna7027Q3
Peter8027Q3
Mary9027Q3
Anna10028Q3
Peter11028Q3
Mary12028Q3

 

Then, I need to create following table with following info:

Sales PersonWeek This Quarter (Q3)Previous Quarter (Q2)
Anna1017050
Peter2021090
Mary3019070

 

The problem is that I have a slicer for Week, so the colum week is filtered ok with the slicer... but the other two colums, which should sum al the values corresponding to this quarter or previous quarter doesnt work because the slicer.

 

Could you please give me a hand?

 

Anonymous 

 

  • Hi,

     

    based on your sample data, you could do this:

    Current quater =
    VAR _cq =
        CALCULATE ( MAX ( 'Table'[QuaterNo] ); ALL ( 'Table' ) )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Amount] );
            FILTER ( ALLEXCEPT ( 'Table'; 'Table'[Sales Person] ); 'Table'[QuaterNo] = _cq )
        )
    Previous quater =
    VAR _cq =
        CALCULATE ( MAX ( 'Table'[QuaterNo] ); ALL ( 'Table' ) ) - 1
    RETURN
        CALCULATE (
            SUM ( 'Table'[Amount] );
            FILTER ( ALLEXCEPT ( 'Table'; 'Table'[Sales Person] ); 'Table'[QuaterNo] = _cq )
        )


    The idea is to find the last quater of you dataset, and then remove all filters except the filters on sales person. I guess your sample dataset is a bit simplified. I guess you have date table in your report/model, so you can make use of the TODAY()-function to identify the current quater. If your data spans several year, you can create a quaterYearNum-column like this ([year]-2010)*4+quaterNumber(2010 is chosen somewhat arbitrarily). This will give you a sequence of quaters, and the previous quater can be refererenced by curretn quaterYearNum-1. In order to get quater number from a date, you can use the format-function: FORMAT(date,"Q").

     

    cheers,

    s
     

     

2 Replies

  • sturlaws's avatar
    sturlaws
    Icon for Resident Rockstar rankResident Rockstar

    Hi,

     

    based on your sample data, you could do this:

    Current quater =
    VAR _cq =
        CALCULATE ( MAX ( 'Table'[QuaterNo] ); ALL ( 'Table' ) )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Amount] );
            FILTER ( ALLEXCEPT ( 'Table'; 'Table'[Sales Person] ); 'Table'[QuaterNo] = _cq )
        )
    Previous quater =
    VAR _cq =
        CALCULATE ( MAX ( 'Table'[QuaterNo] ); ALL ( 'Table' ) ) - 1
    RETURN
        CALCULATE (
            SUM ( 'Table'[Amount] );
            FILTER ( ALLEXCEPT ( 'Table'; 'Table'[Sales Person] ); 'Table'[QuaterNo] = _cq )
        )


    The idea is to find the last quater of you dataset, and then remove all filters except the filters on sales person. I guess your sample dataset is a bit simplified. I guess you have date table in your report/model, so you can make use of the TODAY()-function to identify the current quater. If your data spans several year, you can create a quaterYearNum-column like this ([year]-2010)*4+quaterNumber(2010 is chosen somewhat arbitrarily). This will give you a sequence of quaters, and the previous quater can be refererenced by curretn quaterYearNum-1. In order to get quater number from a date, you can use the format-function: FORMAT(date,"Q").

     

    cheers,

    s
     

     

    • ANAC014's avatar
      ANAC014
      Frequent Visitor

      Works perfectly my friend, thanks so much!



      sturlaws wrote:

      Hi,

       

      based on your sample data, you could do this:

      Current quater =
      VAR _cq =
          CALCULATE ( MAX ( 'Table'[QuaterNo] ); ALL ( 'Table' ) )
      RETURN
          CALCULATE (
              SUM ( 'Table'[Amount] );
              FILTER ( ALLEXCEPT ( 'Table'; 'Table'[Sales Person] ); 'Table'[QuaterNo] = _cq )
          )
      Previous quater =
      VAR _cq =
          CALCULATE ( MAX ( 'Table'[QuaterNo] ); ALL ( 'Table' ) ) - 1
      RETURN
          CALCULATE (
              SUM ( 'Table'[Amount] );
              FILTER ( ALLEXCEPT ( 'Table'; 'Table'[Sales Person] ); 'Table'[QuaterNo] = _cq )
          )


      The idea is to find the last quater of you dataset, and then remove all filters except the filters on sales person. I guess your sample dataset is a bit simplified. I guess you have date table in your report/model, so you can make use of the TODAY()-function to identify the current quater. If your data spans several year, you can create a quaterYearNum-column like this ([year]-2010)*4+quaterNumber(2010 is chosen somewhat arbitrarily). This will give you a sequence of quaters, and the previous quater can be refererenced by curretn quaterYearNum-1. In order to get quater number from a date, you can use the format-function: FORMAT(date,"Q").

       

      cheers,

      s