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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mohanpal
Frequent Visitor

How to divide values from Same column based on filter

mohanpal_0-1660015372703.png

Hi, I have this sample data. I want to create a column 'Percentage' which should divide based on ID and Year. I did manage to write a query but that is aggreating all the projection value and giving me one single value not vaue for each row. 

1 ACCEPTED SOLUTION
liuqi_pbi
Resolver III
Resolver III

Hi @mohanpal 

 

If you accept a DAX method, you can create a calculated column with below DAX. This will add a new column to the table. 

Percentage =
VAR _projectionA =
    MAXX (
        FILTER (
            'Table',
            'Table'[Id] = EARLIER ( 'Table'[Id] )
                && 'Table'[Year] = EARLIER ( 'Table'[Year] )
                && 'Table'[Label] = "A"
        ),
        'Table'[Projection]
    )
VAR _projectionB =
    MAXX (
        FILTER (
            'Table',
            'Table'[Id] = EARLIER ( 'Table'[Id] )
                && 'Table'[Year] = EARLIER ( 'Table'[Year] )
                && 'Table'[Label] = "B"
        ),
        'Table'[Projection]
    )
RETURN
    DIVIDE ( _projectionA, _projectionB )

 

----------------------------------------------------------------------

If this reply helps solve the problem, please mark it as Solution! Kudos are appreciated too!

View solution in original post

2 REPLIES 2
liuqi_pbi
Resolver III
Resolver III

Hi @mohanpal 

 

If you accept a DAX method, you can create a calculated column with below DAX. This will add a new column to the table. 

Percentage =
VAR _projectionA =
    MAXX (
        FILTER (
            'Table',
            'Table'[Id] = EARLIER ( 'Table'[Id] )
                && 'Table'[Year] = EARLIER ( 'Table'[Year] )
                && 'Table'[Label] = "A"
        ),
        'Table'[Projection]
    )
VAR _projectionB =
    MAXX (
        FILTER (
            'Table',
            'Table'[Id] = EARLIER ( 'Table'[Id] )
                && 'Table'[Year] = EARLIER ( 'Table'[Year] )
                && 'Table'[Label] = "B"
        ),
        'Table'[Projection]
    )
RETURN
    DIVIDE ( _projectionA, _projectionB )

 

----------------------------------------------------------------------

If this reply helps solve the problem, please mark it as Solution! Kudos are appreciated too!

StefanoGrimaldi
Resident Rockstar
Resident Rockstar

remember its recommended to get a quicker answer to show a end result of the result you looking to have, quickly as I can see and understand I recommend you using a "group by" of the power query that lets you decide the operation to be done with a certain value column (sum, divei, multipli, count, etc) and group the operation by giving columns as the 2 you need. 

 

hope this helps of get you a little on your way





Did I answer your question? Mark my post as a solution! / Did it help? Give some Kudos!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.