Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Table Visualization Line Calculations

Is it possible to insert into a table visualization a row with a calculation based on other row values? 

 

                             Current Period       Data Source

Sales                 $1,000                          Data table

Gross Profit     $200                          Data table

Expenses           $150                          Data table

Profit                      $50                          Calculation = Gross Profit $200 minus Expenses $150

Profit %                    5%                         Calculation = Profit $50 divided by Sales $1000

 

If yes, then I need some instruction.

 

Thanks.

 

Tim

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could also create a calculated table as below:

New table =
VAR _profit =
    CALCULATE (
        SUM ( 'Table'[Current Period  ] ),
        FILTER ( 'Table', 'Table'[category] = "Gross Profit" )
    )
VAR _expense =
    CALCULATE (
        SUM ( 'Table'[Current Period  ] ),
        FILTER ( 'Table', 'Table'[category] = "Expenses" )
    )
VAR _sales =
    CALCULATE (
        SUM ( 'Table'[Current Period  ] ),
        FILTER ( 'Table', 'Table'[category] = "Sales" )
    )
RETURN
    UNION (
        SELECTCOLUMNS (
            'Table',
            "category", 'Table'[category],
            "Current Period", FORMAT ( 'Table'[Current Period  ], "$#,##0" )
        ),
        ROW (
            "category", "Profit",
            "Current Period", FORMAT ( _profit - _expense, "$#,##0" )
        ),
        ROW (
            "category", "Profit%",
            "Current Period", FORMAT ( DIVIDE ( _profit - _expense, _sales ), "percent" )
        )
    )

And you will see:

vkellymsft_0-1629684559544.png

 

 For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

Anonymous
Not applicable

tsdick_0-1629904026417.png

Hello Kelly, I am encountering an error when I set up the calculated new table using my data.  Any suggestions?

 

Thanks for the sharing this approach.

 

Tim

Hi @Anonymous ,

 

Is your issue solved now?

If so,could you pls mark the reply as answered to close it?

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

Hi  @Anonymous ,

 

Cant tell why by the screenshot.

Could you pls share me your .pbix file for test?

Remember to remove the confidential information.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

DataInsights
Super User
Super User

@Anonymous,

 

Try this solution.

 

1. Create a disconnected table (no relationships) with custom labels to be displayed in the table visual. Sort the Label column by the Index column (this controls the display order in the table visual).

 

DataInsights_0-1629378412302.png

 

2. Create measure Display Amount. It uses measures such as Sales, which can be defined in various ways depending on your data model (could be based on Account number, Category, etc.).

 

Display Amount = 
SWITCH (
    SELECTEDVALUE ( CustomLabel[Label] ),
    "Sales", FORMAT ( [Sales], "$#,##0;($#,##0)" ),
    "Gross Profit", FORMAT ( [Gross Profit], "$#,##0;($#,##0" ),
    "Expenses", FORMAT ( [Expenses], "$#,##0;($#,##0" ),
    "Profit", FORMAT ( [Gross Profit] - [Expenses], "$#,##0;($#,##0" ),
    "Profit %", FORMAT ( DIVIDE ( [Gross Profit] - [Expenses], [Sales] ), "Percent" )
)

Sales = CALCULATE ( SUM ( Ledger[Amount] ), Ledger[Category] = "Sales" )

 

3. Create visual:

 

DataInsights_1-1629378702400.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.