Forum Discussion

piotrgrendus87's avatar
3 years ago

How to calculate sum using IF function

Hello.
I would like to know if there is a way to do sum when using the IF function. Below is an example of my problem 

 
I have three metrics:
Today, Today 1 and Today 3, for every metrics there is a goal. To count who achieved the goal and who didn't, I used the logic below:

 

Test Logic = IF([Today]>=[Goal],1,0)
Test Logic 1 = IF([Today 1]>=[Goal 1],1,0)
Test Logic 2 = IF([Today 2]>=[Goal 2],1,0)
 
To sum all of this I used below formula:
Test Logic Sum = [Test Logic] + [Test Logic 1] + [Test Logic 2]
 
This allow me to sum numbers in rows but I still have it a problem with sum a columns.
 
Test Logic should be 2
Test Logic 1 should be 2
Test Logic 2 should be 4
 
To calculated Score I used this formula:
 
Test Logic Sum = DIVIDE([Test Logic] + [Test Logic 1] + [Test Logic 2],3,0)
 
Is there is a better to way to calculate this numbers correct ?
 
Regards Piotr.

1 Reply

  • Manoj_Nair's avatar
    Manoj_Nair
    Solution Supplier

    piotrgrendus87- Did you tried using this. I just made a small changes in your proposed DAX measure. Let me know if this works.

    Test Logic Average = DIVIDE([Test Logic Sum], 3, 0)