Forum Discussion

SR11's avatar
SR11
Frequent Visitor
7 years ago
Solved

Update columns based on slicer selection

This might be a newbie question but I am trying to find the best way to show data from multiple branches over time. And the end goal is to be able to select one, multiple or all branches in a slicer and update the report. 

 

The underlying data looks like this- 

BranchData Table

DateDescriptionBranch1Branch2Branch3Branch4
8/1/2018Net10020075150
8/1/2018Rebilling25152035
8/1/2018Customer Billing60254550
8/1/2018Retainage25455585
7/1/2018Net120150200100
7/1/2018Rebilling15202515
7/1/2018Customer Billing503510050
7/1/2018Retainage25255025
6/1/2018Net200100150100
6/2/2018Rebilling55253515
6/3/2018Customer Billing1505010055
6/4/2018Retainage35252045
5/1/2018Net100200150100
5/1/2018Rebilling15501535
5/1/2018Customer Billing801208555
5/1/2018Retainage10452520

 

Then I am using a custom table with calculated columns to get some data based on the values above-

CollectionPercent Table

DateBranch1Branch2Branch3Branch4
8/1/20187.77%28.86%1.49%8.84%
7/1/201815.10%38.95%8.55%23.11%
6/1/201818.56%35.79%9.14%22.25%
5/1/201820.00%28.79%11.71%14.24%

 

This table is then being used to build line charts to see data for each branch over time. I would like to add a slicer for Branch and see line charts for one, multiple or all branches. What is the best way to do this? If there is a better was to get to this line chart, then I am open to changing up the way I am getting to the second table. Please advice. 

  • (I will assume the 6/2, 6/3, and 6/4 in your demo are typos)

     

    First, you will want unpivot your data so you have a single combination of Branch and Description on a single line. Otherwise you will have to create a separate measure for each branch (and I assume you have more than 4 branches).  In the Query Editor, highlight all of the "branch columns", and on the "Transform" tab click "Unpivot Columns" and "Unpivot Only Selected Columns".

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    This will get your data in a better format for DAX. You'll probably want to make sure the columns have names that mean something as it defaults to "Attribute" and "Value".

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Now you create your formula as a measure (I only have the one table, so you'll have to modify, but this is the pattern you'll want)

     

     

    Collection Percent = 
    DIVIDE(
        CALCULATE(SUM(Branches[Value]), Branches[Description] = "Net") 
            - CALCULATE(SUM(Branches[Value]), Branches[Description]="Retainage"),
        6)

     

     

    Now create a matrix visual with Date on the rows and BranchNo on the Columns and you'll see the same as your calculated table. Create a slicer for BranchNo (on formatting under "Selection Controls" turn "Show Select All option" to ON and "Single Select" to OFF). Then create a line chart with Axis = Date, Legend = BranchNo, and Value = Collection Percent.  The slicer will show only the branches you have chosen (in this example I disabled the interaction between the slicer and the matrix).

     

    One branch

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    All branches

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Two branches

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Hope this helps

    David 

10 Replies

  • dedelman_clng's avatar
    dedelman_clng
    Community Champion

    You likely want to use measures instead of your calculated table/columns.  Measures automatically recalculate when slicers are applied. A slicer visual can be set up with "Select All" and Multi-select to get 1, group or all branches.

     

    What is the formula for getting the Collection Percent?

    • SR11's avatar
      SR11
      Frequent Visitor

      Branch1= (CALCULATE(MAX(BranchData[Branch1]),filter(BranchData,BranchData[Date]='CollectionTable'[Date]&&BranchData[Description]="Net")) - CALCULATE(MAX(BranchData[Branch1]),filter(BranchData,BranchData[Date]='CollectionTable'[Dated]&&BranchData[Description]="Retainage")))/6

       

      Please ignore that the values don't match up in the demo tables. I just entered some random data earlier for the sake for visualization.

      • dedelman_clng's avatar
        dedelman_clng
        Community Champion

        (I will assume the 6/2, 6/3, and 6/4 in your demo are typos)

         

        First, you will want unpivot your data so you have a single combination of Branch and Description on a single line. Otherwise you will have to create a separate measure for each branch (and I assume you have more than 4 branches).  In the Query Editor, highlight all of the "branch columns", and on the "Transform" tab click "Unpivot Columns" and "Unpivot Only Selected Columns".

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

        This will get your data in a better format for DAX. You'll probably want to make sure the columns have names that mean something as it defaults to "Attribute" and "Value".

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

        Now you create your formula as a measure (I only have the one table, so you'll have to modify, but this is the pattern you'll want)

         

         

        Collection Percent = 
        DIVIDE(
            CALCULATE(SUM(Branches[Value]), Branches[Description] = "Net") 
                - CALCULATE(SUM(Branches[Value]), Branches[Description]="Retainage"),
            6)

         

         

        Now create a matrix visual with Date on the rows and BranchNo on the Columns and you'll see the same as your calculated table. Create a slicer for BranchNo (on formatting under "Selection Controls" turn "Show Select All option" to ON and "Single Select" to OFF). Then create a line chart with Axis = Date, Legend = BranchNo, and Value = Collection Percent.  The slicer will show only the branches you have chosen (in this example I disabled the interaction between the slicer and the matrix).

         

        One branch

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

        All branches

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

        Two branches

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

         

        Hope this helps

        David