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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
JackCarter
Frequent Visitor

Calculation Group or Measure?

I need to replicate the below in power BI but I am having trouble with the measure to create the % column and I am not sure if I need to have a calculation group or a measure to do so. Very simply put the Percent value for 31011 for example is total balance of 31011 divided by the total of 31010, simple. However to further complicate it, 31017 % is total balance of 31017 divided by total balance of 31016. So essentially the calculation needed for each row depends on the row value (Ledger Account). I have tried the below measure but it says it doesn't have enough memory to complete when I add it to a matrix for example. Any help would be much appreciated!

 

 

% = VAR GL = SELECTEDVALUE('GL FACT (Combined) (ABV)'[GL ACCOUNT])
VAR Perc = Switch(TRUE(),
GL="31011",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31011")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31012",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31012")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31017",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31017")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31016"))),
GL="31018",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31018")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31016"))),
GL="31040",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31040")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31041",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31041")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31040"))),
GL="31042",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31042")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31040"))),
GL="31043",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31043")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31044",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31044")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31043"))),
GL="31045",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31045")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31043"))),
GL="31054",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31054")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31055",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31055")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31054"))),
GL="31056",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31056")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31054"))),
GL="31080",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31056")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31107",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31056")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31130",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31056")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31131",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31056")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31133",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31056")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31134",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31056")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31136",DIVIDE(CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]="31056")),CALCULATE([BRL Amount],Filter(ALL('GL FACT (Combined) (ABV)'[GL ACCOUNT]),'GL FACT (Combined) (ABV)'[GL ACCOUNT]= "31010"))),
GL="31010",BLANK(),
GL="31013",BLANK(),
GL="31014",BLANK(),
GL="31015",BLANK(),
GL="31050",BLANK()
)
Return
Perc

 

JackCarter_1-1699363638991.png

 

 

1 REPLY 1
DataInsights
Super User
Super User

@JackCarter,

 

Have you tried shifting any of the logic upstream? For example, you could create calculated columns in the fact table that precompute the numerator and denominator. The logic in the first argument of DIVIDE would be moved to calculated column [PERC NUMERATOR] and the second argument of DIVIDE would be move to calculated column [PERC DENOMINATOR]. Then create a SUM measure for each calculated column. The excerpt below

 

% =
VAR GL =
    SELECTEDVALUE ( 'GL FACT (Combined) (ABV)'[GL ACCOUNT] )
VAR Perc =
    SWITCH (
        TRUE (),
        GL = "31107",
            DIVIDE (
                CALCULATE (
                    [BRL Amount],
                    FILTER (
                        ALL ( 'GL FACT (Combined) (ABV)'[GL ACCOUNT] ),
                        'GL FACT (Combined) (ABV)'[GL ACCOUNT] = "31056"
                    )
                ),
                CALCULATE (
                    [BRL Amount],
                    FILTER (
                        ALL ( 'GL FACT (Combined) (ABV)'[GL ACCOUNT] ),
                        'GL FACT (Combined) (ABV)'[GL ACCOUNT] = "31010"
                    )
                )
            ),
        GL = "31050", BLANK ()
    )
RETURN
    Perc

 

can be rewritten as

 

% =
SWITCH (
    SELECTEDVALUE ( 'GL FACT (Combined) (ABV)'[GL ACCOUNT] ),
    "31107", DIVIDE ( [Perc Numerator], [Perc Denominator] ),
    "31050", BLANK ()
)

 





Did I answer your question? Mark my post as a solution!

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! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.