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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
frankhofmans
Helper IV
Helper IV

Add row in dashboard table

hi PBI experts,

 

I have the following question: i have a data table with P&L data. The structure is as following:

 

PeriodP&L levelValueReporting level
2021-1Net Sales1500000Actuals
2021-1COS-650000Actuals
2021-1Direct Costs-500000Actuals
2021-1Other operating expenses-265000Actuals
2021-1Depr. & Am.-25000Actuals
2021-2Net Sales1800000Actuals
2021-2COS-700000Actuals
2021-2Direct Costs-600000Actuals
2021-2Other operating expenses-270000Actuals
2021-2Depr. & Am.-25000Actuals
2021-3Net Sales2000000Actuals
2021-3COS-800000Actuals
2021-3Direct Costs-700000Actuals
2021-3Other operating expenses-300000Actuals
2021-3Depr. & Am.-26000Actuals
2021-1Net Sales1600000Budget
2021-1COS-700000Budget
2021-1Direct Costs-480000Budget
2021-1Other operating expenses-265000Budget
2021-1Depr. & Am.-25000Budget
2021-2Net Sales1700000Budget
2021-2COS-675000Budget
2021-2Direct Costs-575000Budget
2021-2Other operating expenses-250000Budget
2021-2Depr. & Am.-25000Budget
2021-3Net Sales2100000Budget
2021-3COS-830000Budget
2021-3Direct Costs-720000Budget
2021-3Other operating expenses-290000Budget
2021-3Depr. & Am.-27000Budget

 

I want to create a P&L in the dashboard, but with Gross Margin (Net Sales + COS), Gross Profit (Net Sales + COS + Direct Costs), EBITDA (Net Sales + COS + Direct Costs + Other operating expenses) and EBIT (Net Sales + COS + Direct Costs + Other operating expenses + Depr. & Am.). This should result in the following P&L:

 

 ActualsBudgetActuals vs Budget variance
Net Sales   
Cos   
Gross Margin   
Direct Costs   
Gross Profit   
Other Operating Expenses   
EBITDA   
Depr. & Am.   
EBIT   

 

Who can help me with the solution?

 

Many thanks in advance,

 

Regards, Frank

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @frankhofmans 

I think this is not a good idea to add Gross Margin %, Gross Profit %, EBITDA % which are in Percentage format into original result. We can see that original result is in whole number format. In Power BI, one measure or column can have only one format. So if you want to add % in your original result, you will need to change the measure format to text, or you have to show Gross Margin %, Gross Profit %, EBITDA % in decimal number format instead of % format. Neither of them are good ideas. 

Here I add Gross Margin % in origianl code.

Matrix Table = 
VAR _NewPLlevel =
    UNION (
        VALUES ( 'Table'[P&L level] ),
        { "Gross Margin","Gross Margin %","Gross Profit","EBITDA", "EBIT" }
    )
VAR _AddSort =
    ADDCOLUMNS (
        _NewPLlevel,
        "PLsort",
            SWITCH (
                [P&L level],
                "Net Sales", 1,
                "COS", 2,
                "Direct Costs", 3,
                "Other operating expenses", 4,
                "Depr. & Am.", 5,
                "Gross Margin", 6,
                "Gross Margin %",7,
                "Gross Profit", 8,
                "EBITDA", 9,
                10
            )
    )
RETURN
    _AddSort

And I create a new Actual measure as a example.

Actuals = 
VAR _CurrentPL =
    MAX ( 'Matrix Table'[P&L level] )
VAR _INRANGEAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level] = MAX ( 'Matrix Table'[P&L level] )
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _GMAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _NetSales =     
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level] = "Net Sales"
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _GMActPercent = DIVIDE(_GMAct,_NetSales)
VAR _GPAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS", "Direct Costs" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _EBITDAAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS", "Direct Costs", "Other operating expenses" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _EBITAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN {
                "Net Sales",
                "COS",
                "Direct Costs",
                "Other operating expenses",
                "Depr. & Am."
            }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
RETURN
    SWITCH (
        TRUE (),
        _CurrentPL IN VALUES ( 'Table'[P&L level] ), _INRANGEAct,
        _CurrentPL = "Gross Margin", _GMAct,
        _CurrentPL = "Gross Margin %",_GMActPercent,
        _CurrentPL = "Gross Profit", _GPAct,
        _CurrentPL = "EBITDA", _EBITDAAct,
        _CurrentPL = "EBIT", _EBITAct
    )

You see I need to change the measure format to decimal number. If you want to change measure to text, it is complex to update your code.

1.png

Here I suggest you to build a new Matrix Table2 with above code.

Matrix Table 2 = 
VAR _NewPLlevel =
        {"Gross Margin %","Gross Profit%","EBITDA%", "EBIT%" }
VAR _AddSort =
    ADDCOLUMNS (
        _NewPLlevel,
        "PLsort",
            SWITCH (
                [Value],
                "Gross Margin %", 1,
                "Gross Profit%", 2,
                "EBITDA%", 3,
                "EBIT%", 4,
                5  
            )
    )
RETURN
    _AddSort

Then you can refer to above measure to create a new measure to show Gross Margin %, Gross Profit %, EBITDA % in the new Matrix. Then you can set your measure format as percentage. 

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @frankhofmans 

Try to build a New P&L level Table by Dax then build measures as below.

Matrix Table = 
VAR _NewPLlevel =
    UNION (
        VALUES ( 'Table'[P&L level] ),
        { "Gross Margin", "Gross Profit", "EBITDA", "EBIT" }
    )
VAR _AddSort =
    ADDCOLUMNS (
        _NewPLlevel,
        "PLsort",
            SWITCH (
                [P&L level],
                "Net Sales", 1,
                "COS", 2,
                "Direct Costs", 3,
                "Other operating expenses", 4,
                "Depr. & Am.", 5,
                "Gross Margin", 6,
                "Gross Profit", 7,
                "EBITDA", 8,
                9
            )
    )
RETURN
    _AddSort

Table:

1.png

We can sort New P&L level column by PLsort column.

Measures:

Actuals = 
VAR _CurrentPL =
    MAX ( 'Matrix Table'[P&L level] )
VAR _INRANGEAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level] = MAX ( 'Matrix Table'[P&L level] )
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _GMAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _GPAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS", "Direct Costs" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _EBITDAAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS", "Direct Costs", "Other operating expenses" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _EBITAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN {
                "Net Sales",
                "COS",
                "Direct Costs",
                "Other operating expenses",
                "Depr. & Am."
            }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
RETURN
    SWITCH (
        TRUE (),
        _CurrentPL IN VALUES ( 'Table'[P&L level] ), _INRANGEAct,
        _CurrentPL = "Gross Margin", _GMAct,
        _CurrentPL = "Gross Profit", _GPAct,
        _CurrentPL = "EBITDA", _EBITDAAct,
        _CurrentPL = "EBIT", _EBITAct
    )
Budget = 
VAR _CurrentPL =
    MAX ( 'Matrix Table'[P&L level] )
VAR _INRANGEBud =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level] = MAX ( 'Matrix Table'[P&L level] )
                && 'Table'[Reporting level] = "Budget"
        )
    )
VAR _GMBud=
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS" }
                && 'Table'[Reporting level] = "Budget"
        )
    )
VAR _GPBud =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS", "Direct Costs" }
                && 'Table'[Reporting level] = "Budget"
        )
    )
VAR _EBITDABud =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS", "Direct Costs", "Other operating expenses" }
                && 'Table'[Reporting level] = "Budget"
        )
    )
VAR _EBITBud =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN {
                "Net Sales",
                "COS",
                "Direct Costs",
                "Other operating expenses",
                "Depr. & Am."
            }
                && 'Table'[Reporting level] = "Budget"
        )
    )
RETURN
    SWITCH (
        TRUE (),
        _CurrentPL IN VALUES ( 'Table'[P&L level] ), _INRANGEBud,
        _CurrentPL = "Gross Margin", _GMBud,
        _CurrentPL = "Gross Profit", _GPBud,
        _CurrentPL = "EBITDA", _EBITDABud,
        _CurrentPL = "EBIT", _EBITBud
    )
Actuals vs Budget variance = [Actuals] - [Budget]

Result is as below.

2.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hi Rico,

 

This works for me. Many thanks! is it also possible to add Gross Margin % (Gross Margin / Net Sales) under Gross Margin, Gross Profit % under Gross Profit and EBITDA % under EBITDA?

 

Regards,

 

Frank

Anonymous
Not applicable

Hi @frankhofmans 

I think this is not a good idea to add Gross Margin %, Gross Profit %, EBITDA % which are in Percentage format into original result. We can see that original result is in whole number format. In Power BI, one measure or column can have only one format. So if you want to add % in your original result, you will need to change the measure format to text, or you have to show Gross Margin %, Gross Profit %, EBITDA % in decimal number format instead of % format. Neither of them are good ideas. 

Here I add Gross Margin % in origianl code.

Matrix Table = 
VAR _NewPLlevel =
    UNION (
        VALUES ( 'Table'[P&L level] ),
        { "Gross Margin","Gross Margin %","Gross Profit","EBITDA", "EBIT" }
    )
VAR _AddSort =
    ADDCOLUMNS (
        _NewPLlevel,
        "PLsort",
            SWITCH (
                [P&L level],
                "Net Sales", 1,
                "COS", 2,
                "Direct Costs", 3,
                "Other operating expenses", 4,
                "Depr. & Am.", 5,
                "Gross Margin", 6,
                "Gross Margin %",7,
                "Gross Profit", 8,
                "EBITDA", 9,
                10
            )
    )
RETURN
    _AddSort

And I create a new Actual measure as a example.

Actuals = 
VAR _CurrentPL =
    MAX ( 'Matrix Table'[P&L level] )
VAR _INRANGEAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level] = MAX ( 'Matrix Table'[P&L level] )
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _GMAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _NetSales =     
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level] = "Net Sales"
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _GMActPercent = DIVIDE(_GMAct,_NetSales)
VAR _GPAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS", "Direct Costs" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _EBITDAAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN { "Net Sales", "COS", "Direct Costs", "Other operating expenses" }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
VAR _EBITAct =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[P&L level]
                IN {
                "Net Sales",
                "COS",
                "Direct Costs",
                "Other operating expenses",
                "Depr. & Am."
            }
                && 'Table'[Reporting level] = "Actuals"
        )
    )
RETURN
    SWITCH (
        TRUE (),
        _CurrentPL IN VALUES ( 'Table'[P&L level] ), _INRANGEAct,
        _CurrentPL = "Gross Margin", _GMAct,
        _CurrentPL = "Gross Margin %",_GMActPercent,
        _CurrentPL = "Gross Profit", _GPAct,
        _CurrentPL = "EBITDA", _EBITDAAct,
        _CurrentPL = "EBIT", _EBITAct
    )

You see I need to change the measure format to decimal number. If you want to change measure to text, it is complex to update your code.

1.png

Here I suggest you to build a new Matrix Table2 with above code.

Matrix Table 2 = 
VAR _NewPLlevel =
        {"Gross Margin %","Gross Profit%","EBITDA%", "EBIT%" }
VAR _AddSort =
    ADDCOLUMNS (
        _NewPLlevel,
        "PLsort",
            SWITCH (
                [Value],
                "Gross Margin %", 1,
                "Gross Profit%", 2,
                "EBITDA%", 3,
                "EBIT%", 4,
                5  
            )
    )
RETURN
    _AddSort

Then you can refer to above measure to create a new measure to show Gross Margin %, Gross Profit %, EBITDA % in the new Matrix. Then you can set your measure format as percentage. 

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Greg_Deckler
Community Champion
Community Champion

@frankhofmans Just create each of those as measures and then use a matrix visual and use the "show on rows" feature to show your measures on each row. The other approach would be to create a disconnected table with your categories and use an additional "measure to show" measure. That is the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors