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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
EdgarasR1
Frequent Visitor

Need help with Formula

Hello,

 

I need help with formula because I can't figure out why that simple formula doesn't works.

Example:

 

I have this table. 

I used this formula:

COLUMN3 = IF('Planas vs Faktas'[Plan]-'Planas vs Faktas'[Fact]<=0;0;'Planas vs Faktas'[Plan]-'Planas vs Faktas'[Fact])
 
So, I want to subtract PLAN - FACT, by every month, and if FACT was bigger than PLAN, it have to be 0 in new column.
So, like you see in 2019-10-31 Fact was bigger than Plan. That's mean PLAN was achieved.
If PLAN was bigger than FACT, in new column its just have to be PLAN-FACT. But like you see by this formula Im just getting PLAN's numbers. 

 

Capture.JPG

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @EdgarasR1 

You can create a measure like so to get your result.

Measure = 
VAR _Fact = SUM ( 'Planas vs Faktas'[Fact] )
VAR _Plan = SUM ( 'Planas vs Faktas'[Plan] )
RETURN IF ( _Fact > _Plan, 0, _Plan - _Fact )

PlanFact.jpg 

 

You should create measures for each of the amount though then use those measures.

Fact Amount = SUM ( 'Planas vs Faktas'[Fact] )
Plan Amount = SUM ( 'Planas vs Faktas'[Plan] )
Plan-Fact = [Plan Amount] - [Fact Amount]

Then the final measure would be just this:

Measure = IF ( [Fact Amount] > [Plan Amount], 0, [Plan-Fact] )

 

 

 

View solution in original post

1 REPLY 1
jdbuchanan71
Super User
Super User

Hello @EdgarasR1 

You can create a measure like so to get your result.

Measure = 
VAR _Fact = SUM ( 'Planas vs Faktas'[Fact] )
VAR _Plan = SUM ( 'Planas vs Faktas'[Plan] )
RETURN IF ( _Fact > _Plan, 0, _Plan - _Fact )

PlanFact.jpg 

 

You should create measures for each of the amount though then use those measures.

Fact Amount = SUM ( 'Planas vs Faktas'[Fact] )
Plan Amount = SUM ( 'Planas vs Faktas'[Plan] )
Plan-Fact = [Plan Amount] - [Fact Amount]

Then the final measure would be just this:

Measure = IF ( [Fact Amount] > [Plan Amount], 0, [Plan-Fact] )

 

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors