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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
zibster
Helper III
Helper III

Percent from top

Hi, I am trying to get percentage in power Bi by dividing items designated as line 2 by the same items amount designated as line 1, and when there is no match of items like in scenario of Other the item amount would be divided by Total Line 1. The data table looks the same as the example without the percent's

 

LineItemSalesPercent
1Water6000 
1Orange5000 
1Apple5000 
1Total16000 
    
2Water5409.00%
2Orange2865.72%
2Apple97519.50%
2Other6504.06%

 

 

Thanks 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1663385159302.png

 

Percent CC =
IF (
    Data[Line] = 2,
    VAR _lineonesales =
        SUMX (
            FILTER ( Data, Data[Item] = EARLIER ( Data[Item] ) && Data[Line] = 1 ),
            Data[Sales]
        )
    VAR _linetwosales = Data[Sales]
    VAR _lineonetotalsales =
        SUMX ( FILTER ( Data, Data[Item] = "Total" && Data[Line] = 1 ), Data[Sales] )
    VAR _result =
        DIVIDE ( _linetwosales, _lineonesales )
    RETURN
        FORMAT (
            IF (
                ISBLANK ( _result ),
                DIVIDE ( _linetwosales, _lineonetotalsales ),
                _result
            ),
            "#,#0.00%"
        )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

3 REPLIES 3
zibster
Helper III
Helper III

Thank you, this is great.

 

😀

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Jihwan_Kim_0-1663385159302.png

 

Percent CC =
IF (
    Data[Line] = 2,
    VAR _lineonesales =
        SUMX (
            FILTER ( Data, Data[Item] = EARLIER ( Data[Item] ) && Data[Line] = 1 ),
            Data[Sales]
        )
    VAR _linetwosales = Data[Sales]
    VAR _lineonetotalsales =
        SUMX ( FILTER ( Data, Data[Item] = "Total" && Data[Line] = 1 ), Data[Sales] )
    VAR _result =
        DIVIDE ( _linetwosales, _lineonesales )
    RETURN
        FORMAT (
            IF (
                ISBLANK ( _result ),
                DIVIDE ( _linetwosales, _lineonetotalsales ),
                _result
            ),
            "#,#0.00%"
        )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi Jihwan,

 

Would you have idea how to fix the % on the subtotal line?

 

zibster_0-1663870845504.png

Thanks Z

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.