Forum Discussion

Mtozero's avatar
Mtozero
Helper I
8 years ago
Solved

Power BI Table In the UI

We have a requirement to display the data in power BI with the below format. 

 

(a) Columns as Rolling 12 months,(show individual month), Previous 12 Months overall total, Current 12 Months and the variance of current and Previous 12 Months

(b) Average for each column 

(c) Color the column based on the Average. Note the column values should display values. 

 

 

 


14 Replies

  • Here's a pbi file that does most of what you are looking for, Mtozero.

     

    Sadly, it looks like my post where I explained how this works is in moderation....

     

    Short version:

    - disconnected table to setup the context for the report with a couple of calculated columns.

    • -11 to 0 rows are individual months
    • 1 is Trailing Twelve Months; 2 is Trailing Twelve Months last year; 3 is Variance.
    • Variance is the tricky one because it doesn't have just a start and end date.

    Measures to get the appropriate amounts.

     

    Create a matrix visualization with Range field from the Report table on Columns. 

    States or in my case countries on rows.

    Put the final measure on as values.

    Turn off subtotals and grand totals for rows.

    Keep grand totals for columns. 

     

    Conditional formatting options are limited right now. 

     

     

     

     

    • freder1ck's avatar
      freder1ck
      Kudo Kingpin

      You should also set the sort by column for the Range column in the Report table. Sort it by the Value column. This way, the columns in the matrix will line up right.

       

      As you dig into this file, please ask whatever questions you need to. 

       

      Thanks,

       

      Fred

    • Mtozero's avatar
      Mtozero
      Helper I

      Thanks, freder1ck, Appreciate your quick response. 

       

      Do we have any options to dynamically change the column Name of the table?   

       

      • freder1ck's avatar
        freder1ck
        Kudo Kingpin

        Thank you! 

         

        When you say dynamically change the name of the column name, what exactly do you mean?

         

        The column names of the Report table are set when the data is refreshed.

         

        The current month (offset value 0) is 12/31/2017. In a few days, the current month will be 1/31/2018. 

         

        It looks like I put the wrong link in to my personal OneDrive. I'll put the link up after work today.

         

        Fred

         

         

         

  • Hi,

     

    I dont think this can be accomplished in PowerBI desktop.  This can be done in Excel using CUBE formulas.  Share the link from where i can download your base data.

  • Hi Mtozero,

     

    It's possible to get most of this done in Power BI, using a disconnected table that will create the special report form.

    Conditional formatting is a bit limited still. 

    There are 3 steps to this.

    1. Create a disconnected table

    2. Create some measures to populate the table.

    3. Put your measure into an AVERAGEX() so that the total will display as the average of the column.

     

    Disconnected table

    From the Modeling tab of Power BI, select the New Table button. Create the table by putting the following into the formula bar.

    Report = GENERATESERIES(-11, 3, 1)

    This creates a table of values from -11 to +3 (incrementing at 1).

     

    • -11 to 0 will be the actual months.
    • 1 will be TTM.
    • 2 will be TTM LY3 will be Variance.

     

    We need an end date and a start date for each row of this table to filter the sales data. 

     

    Then, add some columns to your Report table.

     

    End Date =
    IF (
        Report[Value] < 1,
        EOMONTH ( TODAY (), Report[Value] ),
        IF (
            Report[Value] = 1,
            EOMONTH ( TODAY (), -1 ),
            IF ( Report[Value] = 2, EOMONTH ( TODAY (), -13 ), EOMONTH ( TODAY (), -1 ) )
        )
    )

      

    The second column is Start Date

     

    Start Date =
    IF (
        Report[Value] < 1,
        DATE ( YEAR ( Report[End Date ] ), MONTH ( Report[End Date ] ), 1 ),
        EOMONTH ( Report[End Date ], -12 ) + 1
    )

     

    Start date is the beginning of the month for actual months

    For other periods, it's 12 months back.

    You can verify the date periods in the data view of the Report table (and change as needed).

     

    Range =
    IF (
        Report[Value] < 1,
        FORMAT ( Report[End Date ], "" ),
        IF ( Report[Value] = 1, "TTM", IF ( Report[Value] = 2, "TTM LY", "Variance" ) )
    )

     

    This is the last column added to the table. It's the name of the column. This will go onto rows in a matrix visualization.

     

    The basic measure is PdSales. PdSales is the calculation for all ranges except Variance. 

     

    Total Sales = SUM(Sales[Amount])

    PdSales = CALCULATE (
            [Total Sales],
            DATESBETWEEN (
                'Dates'[Date],
                MIN ( Report[Start Date] ),
                MAX ( Report[End Date ] )
            )
        )

     

    Period Sales measure switches between PdSales and Variance.

     

    Period Sales  =
    IF(MAX(Report[Value]) < 3,
        [PdSales],
        [Variance]
    )

     

    Variance is TTM - TTM LY

     

    Variance =
        CALCULATE([PdSales],
      ALL(Report),
      Report[Value]=1)
    -
    CALCULATE ([PdSales],
     ALL(report),
     Report[Value]=2
            )

     

    The third thing we need is the AVERAGEX to make the totals come out as averages.

     

    Average Period Sales = AVERAGEX(Territories, [Period Sales ])

     

    To build your matrix, put Range field on columns and Territory (aka State) on rows.

    Turn off subtotals and row totals. Keep column totals on.

     

    Thanks,

    Fred Kaffenberger
    Kansas City Metro

     

    And here's a OneDrive link to the pbix