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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
M_SBS_6
Helper V
Helper V

Calulation of values within the same column

Hi,

 

I have the following calculation that provides me with the majority of the output required and can be seen within the table below.

 

SUMX(

apps,

IF('apps'[app_cat] in {"INT","YTL","NB"} && apps[curr_month_or_after] = "No", "",

IF('apps'[app_cat] in {"INT"} && apps[curr_month_or_after] = "No" ||

'apps'[app_cat] = "INT" && 'apps'[app_type] = 1,

('apps'[amount] * apps[app_curr]) / 100,

'apps'[amount]))

)

 

app_catJanFebMarchAprilMayJuneJulyAugSep
INT1000001200001558002856120000    
YTL    5000070000855007500080000
NB    10002000210015001890
FR    15001500150015001500

 

However, what I need to do is where curr_month = "Yes" (i.e May) then I need a calculation that will say somthing like this:

SUM(IF('apps'[amount], 'apps'[app_cat] = "YTL" && apps[curr_month] = "Yes"

-  

'apps'[app_cat] = "INT" && apps[curr_month] = "Yes"

 

of which I have attempted to do here in red but the values don't change:

SUMX(
apps,

(if(apps[curr_month] = "Yes" && 'apps'[app_cat] = "YTL", 'apps'[amount]
-
if(apps[curr_month] = "Yes" && 'apps'[app_cat] = "INT", 'apps'[amount]),

IF('apps'[app_cat] in {"INT","YTL","NB"} && apps[curr_month_or_after] = "No", "",

IF('apps'[app_cat] in {"INT"} && apps[curr_month_or_after] = "No" ||

'apps'[app_cat] = "INT" && 'apps'[app_type] = 1,

('apps'[amount] * apps[app_curr]) / 100,

'apps'[amount]))

)


Then my table output should show like this (changes to the values in RED). So the value in May for app_cat "YTL" has a reduced value by 20000 as that's that value in app_cat "INT"

app_catJanFebMarchAprilMayJuneJulyAugSep
INT1000001200001558002856120000    
YTL    3000070000855007500080000
NB    10002000210015001890
FR    15001500150015001500


Any idea how I could look to add in this logic to my existing please? 

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

Hi @M_SBS_6 ,

According to your description, here's my solution.

SUMX (
    apps,
    IF (
        apps[curr_month] = "Yes"
            && 'apps'[app_cat] = "INT",
        'apps'[amount],
        IF (
            apps[curr_month] = "Yes"
                && 'apps'[app_cat] = "INT",
            'apps'[amount]
                - SUMX (
                    FILTER ( ALL ( apps ), apps[curr_month] = "Yes" && 'apps'[app_cat] = "INT" ),
                    'apps'[amount]
                ),
            IF (
                'apps'[app_cat]
                    IN { "INT", "YTL", "NB" }
                    && apps[curr_month_or_after] = "No",
                "",
                IF (
                    'apps'[app_cat]
                        IN { "INT" }
                        && apps[curr_month_or_after] = "No"
                        || 'apps'[app_cat] = "INT"
                        && 'apps'[app_type] = 1,
                    ( 'apps'[amount] * apps[app_curr] ) / 100,
                    'apps'[amount]
                )
            )
        )
    )
)

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

Best regards,

Community Support Team_yanjiang

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @M_SBS_6 ,

According to your description, here's my solution.

SUMX (
    apps,
    IF (
        apps[curr_month] = "Yes"
            && 'apps'[app_cat] = "INT",
        'apps'[amount],
        IF (
            apps[curr_month] = "Yes"
                && 'apps'[app_cat] = "INT",
            'apps'[amount]
                - SUMX (
                    FILTER ( ALL ( apps ), apps[curr_month] = "Yes" && 'apps'[app_cat] = "INT" ),
                    'apps'[amount]
                ),
            IF (
                'apps'[app_cat]
                    IN { "INT", "YTL", "NB" }
                    && apps[curr_month_or_after] = "No",
                "",
                IF (
                    'apps'[app_cat]
                        IN { "INT" }
                        && apps[curr_month_or_after] = "No"
                        || 'apps'[app_cat] = "INT"
                        && 'apps'[app_type] = 1,
                    ( 'apps'[amount] * apps[app_curr] ) / 100,
                    'apps'[amount]
                )
            )
        )
    )
)

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

Best regards,

Community Support Team_yanjiang

M_SBS_6
Helper V
Helper V

I don't suppose anyone has a suggestion at all please? I really don't know where to go with this. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors