cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mtozero Regular Visitor
Regular Visitor

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. 

 

 

 


Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
freder1ck Member
Member

Re: Power BI Table In the UI

14 REPLIES 14
Super User
Super User

Re: Power BI Table In the UI

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.

freder1ck Member
Member

Re: Power BI Table In the UI

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. 

disc report1.png

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

freder1ck Member
Member

Re: Power BI Table In the UI

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. 

 

disc report1.png

 

 

 

freder1ck Member
Member

Re: Power BI Table In the UI

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 Regular Visitor
Regular Visitor

Re: Power BI Table In the UI

Thanks, @freder1ck, Appreciate your quick response. 

 

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

 

freder1ck Member
Member

Re: Power BI Table In the UI

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

 

 

 

freder1ck Member
Member

Re: Power BI Table In the UI

Highlighted
Mtozero Regular Visitor
Regular Visitor

Re: Power BI Table In the UI

thanks @freder1ck for your response. Appreciate your support. 

 

My problem is with the disconnected table since we need to more slicers. 

 

So what I was thinking let's assume there is no disconnected table. If I can add 12 measures (DAX for each month). It might work but the problem is how to make the measure name/column name dynamically changing.

 

freder1ck Member
Member

Re: Power BI Table In the UI


@Mtozero wrote:

thanks @freder1ck for your response. Appreciate your support. 

 

My problem is with the disconnected table since we need to more slicers. 

 

So what I was thinking let's assume there is no disconnected table. If I can add 12 measures (DAX for each month). It might work but the problem is how to make the measure name/column name dynamically changing.

 



Could you describe a bit more the final result you're looking for? The results here can be sliced by Country, Territory, etc. You could even add a slicer on the disconnected table to show only specific columns. Are you looking to slice according to year and month instead of current state?

 

 

Helpful resources

Announcements
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Users Online
Currently online: 232 members 2,866 guests
Please welcome our newest community members: