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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
SMYAguirre
Frequent Visitor

Divide every row in a Matrix by a static calculated row

I am not entirely sure how to ask this question, but I will give it my best shot.  I am fairly new to Power BI, but worked in other data modeling/reporting systems. 

 

We have found that income statments are not easy in Power BI, but we have managed a work-around with the exception of one area.  We need to get the percentage of each row against Revenue.  So, for example, every row in the matrix below should divide against the highlighted revenue value.  However, nothing we have tried will make that figure static down the rows and as a result, the percentages get wacky.  

 

SMYAguirre_3-1668969414620.png

 

The model looks as follows:

SMYAguirre_1-1668969217418.png

 

We have searched the internet for solutions, tried every type of measure we could find, attemped a few creative measures of our own, created a grouped "revenue only" table using a primary key to sum those totals in measures.  

Any help is greatly appreciated.  Until this is resolved, these reports are being manually distributed to the sales team.  

 

 

 

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

Hi @SMYAguirre ,

 

Please try:

Measure =
VAR _a =
    SUM ( TransactionsAgg[GLTotalAmount_Rev] )
VAR _b =
    CALCULATE (
        SUM ( TransactionsAgg[GLTotalAmount_Rev] ),
        FILTER ( ALL ( '..Report Structure' ), [GL Category] = "Revenue" ),
        REMOVEFILTERS (
            TransactionsAgg[ChartOfAccounts.GL Sub Category],
            TransactionsAgg[ChartOfAccounts.GL_Code_Desc]
        )
    )
RETURN
    DIVIDE ( _a, _b )

Final output:

vjianbolimsft_1-1669095123494.png

Best Regards,

Jianbo Li

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

7 REPLIES 7
v-jianboli-msft
Community Support
Community Support

Hi @SMYAguirre ,

 

Please try:

Measure =
VAR _a =
    SUM ( TransactionsAgg[GLTotalAmount_Rev] )
VAR _b =
    CALCULATE (
        SUM ( TransactionsAgg[GLTotalAmount_Rev] ),
        FILTER ( ALL ( '..Report Structure' ), [GL Category] = "Revenue" ),
        REMOVEFILTERS (
            TransactionsAgg[ChartOfAccounts.GL Sub Category],
            TransactionsAgg[ChartOfAccounts.GL_Code_Desc]
        )
    )
RETURN
    DIVIDE ( _a, _b )

Final output:

vjianbolimsft_1-1669095123494.png

Best Regards,

Jianbo Li

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

Thank you so much!!  This worked and looking at the measure I understand why it worked.  Thank you again!!!

v-jianboli-msft
Community Support
Community Support

Hi @SMYAguirre ,

 

What is your measure TransactionsAgg[GLTotalAmount_Rev]? What does your data look like? Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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

I apologize that I was not clear.  That "TransactionsAgg[GLTotalAmount_Rev]" is the "Value" column you see in the matrix.  I have modified the data and the report so I could share pbix file and the matrix in question.  Please see the link below:

 

https://1drv.ms/u/s!ArrJvtdfd3Ak6im_zT5KDplM4E-C?e=7DNBYu

 

The problem I am having is that while the measure you provided works at the top level, it does not work for the levels beneath (highlighted in screen shot below):

SMYAguirre_0-1669054644702.png

 

I hope this makes things more clear.  Thank you!

SMYAguirre
Frequent Visitor

Thank you. This partially worked, but not completely.

I used: 

Measure = DIVIDE(TransactionsAgg[GLTotalAmount_Rev]),CALCULATE(SUM(TransactionsAgg[GLTotalAmount_Rev]), FILTER(ALL(TransactionsAgg),[GL Category]="Revenue")))


So this is dividing the sum of GLTotalAmount by the sum of GLTotalAmount where the GL Category = Revenue, correct? That makes sense, but this is the result.

 

SMYAguirre_1-1668999192635.png

 

The levels below were not populated.  Is there a way to include the lowest level in that measure? 

Thank you again!!

v-jianboli-msft
Community Support
Community Support

Hi @SMYAguirre ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1668996373845.png

Please try:

 

Measure = DIVIDE(SUM('Table'[Value]),CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),[GL Category]="Revenue")))

 

Final output:

vjianbolimsft_1-1668996431619.png

Best Regards,

Jianbo Li

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

Anonymous
Not applicable

this worked for me! but when I apply a filter that changes the total amount in revenue it doesn't consider this change in revenue. For example, if revenue was 200 and then I apply a slicer and it becomes 100 it will still use the 200 revenue as the denominator. 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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