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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
jkoclejda
Helper I
Helper I

Subtract part of value from category X and add to category Y

Hi!

 

I have table Traffic with data like below:

SourceSessions
Google Ads5000
Organic4500
Brand3000
Social Media1000

 

I need to substract 40% of sessions from Brand and add this value to Organic. 

I figured out how to make the first part:

VAR _Brand = CALCULATE((SUM('Traffic'[Sessions]) * 0.4), KEEPFILTERS('Traffic'[Source] = "Brand"))
RETURN
CALCULATE(
    SUM('Traffic'[Sesje]) - _Brand
 
But I have no idea how to "change" the source of the value received from _Brand variable and add it to the Organic. Or maybe I should do it in a completely different way than I started?
 
The result should be such values
SourceSessions
Google Ads5000
Organic5700
Brand1800
Social Media1000
 
I will be grateful for all the tips.
9 REPLIES 9
Anonymous
Not applicable

Hi @jkoclejda ,

I have created a simple sample, please refer to my pbix file to see if it helps you.

Create a column.

Column =
VAR _brand =
    CALCULATE (
        SUM ( 'Table'[Sessions] ) * 0.4,
        FILTER ( ( 'Table' ), 'Table'[Source] = "Brand" )
    )
RETURN
    IF (
        ( 'Table'[Source] ) = "Brand",
        ( 'Table'[Sessions] ) - _brand,
        IF (
            ( 'Table'[Source] ) = "Organic",
            ( 'Table'[Sessions] ) + _brand,
            ( 'Table'[Sessions] )
        )
    )

vpollymsft_0-1666159822638.png

Best Regards

Community Support Team _ Polly

 

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

 

Hi! Thank you for the answer but i have a question. Why there is 5 000 in total for Measure column instead of 13 500?

Anonymous
Not applicable

Hi @jkoclejda ,

5 000 in total for Measure column instead of 13 500

  • The measure is like the following:
Measure = var _brand=CALCULATE(MAX('Table'[Sessions])*0.4,FILTER(ALL('Table'),'Table'[Source]="Brand")) return IF(MAX('Table'[Source])="Brand",MAX('Table'[Sessions])-_brand,IF(MAX('Table'[Source])="Organic",MAX('Table'[Sessions])+_brand,MAX('Table'[Sessions])))
  • The total value returns the max('table'[sessions]', so the max value is 5000.

You can create another measure based on the measure.

Measure = var _brand=CALCULATE(MAX('Table'[Sessions])*0.4,FILTER(ALL('Table'),'Table'[Source]="Brand")) return IF(MAX('Table'[Source])="Brand",MAX('Table'[Sessions])-_brand,IF(MAX('Table'[Source])="Organic",MAX('Table'[Sessions])+_brand,MAX('Table'[Sessions]))) 
 

vpollymsft_0-1666170922817.png

 

Best Regards

Community Support Team _ Polly

 

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

Jihwan_Kim
Super User
Super User

Hi,

Please try the below measure whether it suits yours requirement.

 

Sessions expected outcome measure: =
VAR _Brand =
    CALCULATE (
        SUM ( 'Traffic'[Sessions] ),
        FILTER ( ALL ( Traffic ), Traffic[Source] = "Brand" )
    ) * 0.4
RETURN
    SWITCH (
        SELECTEDVALUE ( Traffic[Source] ),
        "Brand", SUM ( 'Traffic'[Sessions] ) - _Brand,
        "Organic", SUM ( 'Traffic'[Sessions] ) + _Brand,
        SUM ( Traffic[Sessions] )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi!

 

Your solution works perfect with data from my example. I tried to apply it to my real data - my table have much more records and columns. I got stuck trying to apply this to another column.

For example

Source TypeSource GroupSessions
brand google adsBrand1000
brand directBrand2000
organicOrganic3000
campaign 1Google Ads4000

 

And when I try your solution with column Source Group everything is ok. But when it want to do it with column Source Type end substract from brand direct and then add to to organic it doesn't work (only subtraction works) . But when i do the same with brand direct and brand google ads everything is fine and I don't know why. 

Hi,

Thank you for your feedback.

What is the expected outcome of the second example?

Source Type Source Group Sessions
brand google ads Brand 1000
brand direct Brand 2000
organic Organic 3000
campaign 1 Google Ads 4000

 

Or, please share your complete sample pbix file' link with how your expected outcome looks like, and then I can try to look into it to come up with a more accurate solution.

Thanks.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi,

 

Here is my sample pbix file - I reconstructed the issue that i have in my real data

jkoclejda_0-1666170675015.png

 

Anonymous
Not applicable

Hi @jkoclejda ,

Please modify your measure.

sessions_f = 
 VAR _Brand =
    CALCULATE (
        SUM ( 'sample_data'[sessions] ),
        FILTER ( ALL ( 'sample_data' ), 'sample_data'[source_type] = "brand organic" )
    ) * 0.4
RETURN
    SWITCH (
        SELECTEDVALUE ( 'sample_data'[source_group] ),
        "brand", SUM ( 'sample_data'[sessions] ) - _Brand,
        "organic", SUM ( 'sample_data'[sessions]) + _Brand,
        SUM ( 'sample_data'[sessions] )
    )

vpollymsft_0-1666171358049.png

 

If I have misunderstood your meaning, please provide more details.

 

Best Regards

Community Support Team _ Polly

 

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

I must subtract sessions from "brand organic" in "source_type" column and add it to "organic". But on the report, in table will be source_group as column. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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