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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
JG_DOT
Regular Visitor

IF specific value, then calculate with other value

Hi everyone,

 

I thought this was going to be fairly simple, but i guess not.

 

I have a fact in my fact table that i want to change, lets call it Data[Sales].

I have a dimension table with markets,

lets say it looks like this:

Markets_DIM
Markets
Market 1
Market 2

Market 3

Market 4

 

I then want the measure to do the following:

if "Market 1" then show data[sales] sum for "Market 2". If any other value than "Market 1", then use that value to sum Data [Sales].

 Basically I really just want the measure to show market 2's value under market 1 for this particular fact.

this is the data now:

Market           Sales

Market 1        

Market 2        100

Market 3        200

Market 4        300

 

i want the measure to show

Market           Sales

Market 1        100

Market 2        100

Market 3        200

Market 4        300

 

My data model:

JG_DOT_0-1730580720266.png

 

 

Hope it makes sense,
Thanks!

1 ACCEPTED SOLUTION

Hi @JG_DOT ,

 

You can achieve your desired output by writing the two measures below:

 

Market2Sales = 
CALCULATE(
    [Sales value],
    ALL(Market),
    Market[Market] = "Market 2"
)

 

Then, to have Market 1 basically show Market 2's number, use the measure below:

 

Market 1 Adjusted Sales = 
sumx(Market,if(Market[Market]="Market 1",
    [Market2Sales],blank()
)
)

 

You can combine the [Sales value] measure with the second measure above to get your desired output.

DataNinja777_0-1730632697641.png

I have attached an example pbix file for your reference.

 

Best regards,

 

 

View solution in original post

6 REPLIES 6
FreemanZ
Community Champion
Community Champion

hi @JG_DOT ,

 

try like:

1. plot the slicer with a unrelated calculated table like:

Markets_slicer

=VALUES(Markets_dim[Markets])

 

2. plot visuals with a new measure like:

Sale2=

VAR _a=

SELECTEDVALUE(Markets_slicer[Markets])

VAR _b =IF (_a= "Market 1", "Market 2", _a)

VAR _result =

CALCULATE(

    [sales],

    Markets_dim[Markets] = _b

)

RETURN _result

Hi! 
thank you very much for taking the time.

 

This is what I tried myself and I can't seem to get it to work.

Market 1 have blank values for data[sales] in my data, and it doesn't show the data for Market 2 as I want to with this solution unfortunately. 
just to be clear, this is what the data looks like:

Market           Sales

Market 1        

Market 2        100

 

i want the measure to show

Market           Sales

Market 1        100

Market 2        100


I can actually see now that it doesn't necessarily depend on the slicer, I really just want the measure to show market 2's value under market 1 for this particular fact.

 

 What am I doing wrong? ☹️

Hi @JG_DOT ,

 

You can achieve your desired output by writing the two measures below:

 

Market2Sales = 
CALCULATE(
    [Sales value],
    ALL(Market),
    Market[Market] = "Market 2"
)

 

Then, to have Market 1 basically show Market 2's number, use the measure below:

 

Market 1 Adjusted Sales = 
sumx(Market,if(Market[Market]="Market 1",
    [Market2Sales],blank()
)
)

 

You can combine the [Sales value] measure with the second measure above to get your desired output.

DataNinja777_0-1730632697641.png

I have attached an example pbix file for your reference.

 

Best regards,

 

 

Hi! Thank you very much for taking the time.

 

It is not exactly what i'm looking for.

I want the values for all markets in the same collumn, so Market 1 should have Market 2s value, Market 2, 3 and 4 should have their own values - all in the same collumn. 

Besides that i really cant get you measures to work either, i just get blank values for measure 2...

Hi @JG_DOT ,

 

It is very straightforward to produce your required output once Market 1 is populated with Market 2's value 😉.  

To spell it out, it can be produced by the following measure, which generates the visualization shown below.

Required output = [Sales value]+[Market 1 Adjusted Sales]

DataNinja777_0-1730640571144.png

You mentioned that your output came out blank, but I wasn't sure which formula you were using, because my output seems to be coming out OK without producing blank results. Please check the attached pbix file for your reference.

 

Best regards,

 

Hi @DataNinja777 

 

True, i was so focused on keeping the #measures down that i didn't think any further 😀

 

 Anyways, i used your tips and tricks to make this measure that does the job, so thank you very much - i used way to much time on this and you saved me!

 

Sales (Market 1-2) = 
IF(SELECTEDVALUE(Markets_DIM[Markets]) = "Market 1",
CALCULATE(
    SUM(Data[Sales]),
    ALL(Markets_DIM[Markets]),
    Markets_DIM[Markets] = "Market 2"),
CALCULATE(
    SUM(Data[Sales])
))

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.