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
absis
New Member

Divide by row in Power BI


Hi guys,

I've been having a little problem doing something in the matrix.

 

I have the following table

Product            Price         Quantity

AA                   1000           50

BB                    2000          40

CC                   3000           30
DD                  4000           20

 

I need to divide by row and also add more new row like Ratio_CCDD, CC/DD get a result for a row of CC divided by a row of DD product.

The result in Maxtrix should follow:


Product                  Price          Quantity            Amount

AA                         1000            50                      50000

BB                          2000            40                      80000

CC                         3000            30                       90000
Ratio_CCDD          0.75             1.5                      1.125

DD                        4000             20                      80000

 

How can I solve this?

 

Cheers!

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @absis ,

 

At first, you need a calculated column “Amount”.

Amount =
'Table'[Price] * 'Table'[Quantity]

According to the description of your problem, I divide CC by DD. The result will appear in a new table “Table 2”.

Table 2 =
ROW (
    "Product", "Ratio_"
        & CALCULATE (
            SELECTEDVALUE ( 'Table'[Product] ),
            FILTER ( 'Table', 'Table'[Product] = "CC" )
        )
        & CALCULATE (
            SELECTEDVALUE ( 'Table'[Product] ),
            FILTER ( 'Table', 'Table'[Product] = "DD" )
        ),
    "Price", DIVIDE (
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Price] ),
            FILTER ( 'Table', 'Table'[Product] = "CC" )
        ),
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Price] ),
            FILTER ( 'Table', 'Table'[Product] = "DD" )
        )
    ),
    "Quantity", DIVIDE (
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Quantity] ),
            FILTER ( 'Table', 'Table'[Product] = "CC" )
        ),
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Quantity] ),
            FILTER ( 'Table', 'Table'[Product] = "DD" )
        )
    ),
    "Amount", DIVIDE (
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Amount] ),
            FILTER ( 'Table', 'Table'[Product] = "CC" )
        ),
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Amount] ),
            FILTER ( 'Table', 'Table'[Product] = "DD" )
        )
    )
)

Then use UNION() function to combine two tables into one table “Table 3”.

 

Table 3 =
UNION ( 'Table', 'Table 2' )

3-1.PNG

Best Regards,

Eads

 

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

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

1 REPLY 1
v-eachen-msft
Community Support
Community Support

Hi @absis ,

 

At first, you need a calculated column “Amount”.

Amount =
'Table'[Price] * 'Table'[Quantity]

According to the description of your problem, I divide CC by DD. The result will appear in a new table “Table 2”.

Table 2 =
ROW (
    "Product", "Ratio_"
        & CALCULATE (
            SELECTEDVALUE ( 'Table'[Product] ),
            FILTER ( 'Table', 'Table'[Product] = "CC" )
        )
        & CALCULATE (
            SELECTEDVALUE ( 'Table'[Product] ),
            FILTER ( 'Table', 'Table'[Product] = "DD" )
        ),
    "Price", DIVIDE (
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Price] ),
            FILTER ( 'Table', 'Table'[Product] = "CC" )
        ),
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Price] ),
            FILTER ( 'Table', 'Table'[Product] = "DD" )
        )
    ),
    "Quantity", DIVIDE (
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Quantity] ),
            FILTER ( 'Table', 'Table'[Product] = "CC" )
        ),
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Quantity] ),
            FILTER ( 'Table', 'Table'[Product] = "DD" )
        )
    ),
    "Amount", DIVIDE (
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Amount] ),
            FILTER ( 'Table', 'Table'[Product] = "CC" )
        ),
        CALCULATE (
            SELECTEDVALUE ( 'Table'[Amount] ),
            FILTER ( 'Table', 'Table'[Product] = "DD" )
        )
    )
)

Then use UNION() function to combine two tables into one table “Table 3”.

 

Table 3 =
UNION ( 'Table', 'Table 2' )

3-1.PNG

Best Regards,

Eads

 

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

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

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