cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
OvidiuNeacsu Regular Visitor
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): 

 

PBIDesktop_HitMfMLmGk.png

 

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
sturlaws Established Member
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
sturlaws Established Member
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,

 

OvidiuNeacsu Regular Visitor
Regular Visitor

Re: IF & Substraction formulas showing totals wrong

hi @sturlaws 

 

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. 

sturlaws Established Member
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 ()
    )
)



 

 

OvidiuNeacsu Regular Visitor
Regular Visitor

Re: IF & Substraction formulas showing totals wrong

It works @sturlaws !!! Thank you very much !!! Smiley Very Happy

 

 

Helpful resources

Announcements
Community Highlights

Community Highlights

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

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

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.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

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