cancel
Showing results for
Search instead for
Did you mean:
Regular Visitor

## IF & Substraction formulas showing totals wrong

Hello everyone,

I might be doing something wrong with my formulas as it calculates the totals as it shouldn't.

The table looks like this when I add the candidate's ID to see where the issues are (that means that each row is a different candidate):

The formula for the column in the middle is:

From Interview Scheduled to Offer = IF ( ISBLANK([_Average days to Offer]) || ISBLANK([_Average days to Interview - Scheduled]), BLANK(),([_Average days to Offer] - [_Average days to Interview - Scheduled]))

The 1st and last column have these formulas which apply to Whole number columns (that have a different number of days in it or null rows):

_Average days to Interview - ScheduledCALCULATE( AVERAGE([_Days Application to Interview - Scheduled]), FILTER(report, report[_Days Application to Interview - Scheduled] <> 0 ))

_Average days to Offer = CALCULATE( AVERAGE([_Days Application to Offer]), FILTER(report, report[_Days Application to Offer] <> 0 ))

The purpose of the calculations is to ignore all the results that are blank on the other side but in the Total, it doesn't ignore them. In this case, the TOTAL of From Interview Scheduled to Offer should be BLANK() and not "-38"

Is there anything I can do to fix this?

Thank you very much!
1 ACCEPTED SOLUTION

Accepted Solutions
Established Member

## Re: IF & Substraction formulas showing totals wrong

Have you looked at the AVERAGEX-function? It allows for a IF-statement inside the expression part, so you can do something like this

```average =
AVERAGEX (
'Table';
IF (
NOT ( ISBLANK ( [measure1] ) ) && NOT ( ISBLANK ( [measure2] ) );
[measure2] - [measure1];
BLANK ()
)
)```

4 REPLIES 4
Established Member

## Re: IF & Substraction formulas showing totals wrong

Hi,

there might be something I don't understand, but in the total neither [_Average days to Interview - Scheduled] or [_Average days to Offer] is blank, so you get 38 - 76 = -38. Why should it be blank?

best regards,

Regular Visitor

## Re: IF & Substraction formulas showing totals wrong

Thanks for asking,

What I was trying to do is to calculate the time between Interview Scheduled to Offer

That's why I might be wrong in calculating an average of the 2 separately and then subtract them. The only reason I did the average was to take out the 0's and have a measure available.

What I wanted to achieve with the formula below is to have a sort of calculation per Candidate ID that if they didn't pass through Interview Scheduled and Offer, to not calculate a subtraction. And as you can see in the image I attached the column is blank. But the Total is still -38.

From Interview Scheduled to Offer = IF ( ISBLANK([_Average days to Offer]) || ISBLANK([_Average days to Interview - Scheduled]), BLANK(),([_Average days to Offer] - [_Average days to Interview - Scheduled]))

I don't know how to tackle this. I'm out of ideas. What I know is that I have to add something to my formula to be based on each candidate ID.

Hope I made it more clear.

Established Member

## Re: IF & Substraction formulas showing totals wrong

Have you looked at the AVERAGEX-function? It allows for a IF-statement inside the expression part, so you can do something like this

```average =
AVERAGEX (
'Table';
IF (
NOT ( ISBLANK ( [measure1] ) ) && NOT ( ISBLANK ( [measure2] ) );
[measure2] - [measure1];
BLANK ()
)
)```

Regular Visitor

## Re: IF & Substraction formulas showing totals wrong

It works @sturlaws !!! Thank you very much !!!

## Helpful resources

Announcements

#### Community Highlights

Find out what's new in the Power BI Community!

#### Power Platform Summit North America

Register by September 5 to save \$200

#### Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 6 members 3,043 guests
Recent signins:
Please welcome our newest community members: