Forum Discussion

JC3's avatar
JC3
Frequent Visitor
8 years ago

Using IF statement not resulting in correctly summed data

Using the following formula to combine two measures:

 

NS Act+Proj = if([NS Act Total]=0,[NS Proj Total],[NS Act Total])

 

What I want it to do is create a column where "When [NS Act Total] is zero, use values from [NS Proj Total], otherwise use [NS Act Total].

 

The above logic is working when I create a table, but the summation isn't working... summation over the year 2017 is just giving me same result as summing just [NS Act Total]

 

What am I doing wrong? See below for example. 

Adding these columns... leads to just NS Act Total getting added

7 Replies

  • I might be able to help if you provide some detail on your measures and table relationships.

     

    At first glance, it looks like a filter context issue. When you say IF NS Act Total = 0, then return NS Proj Total, otherwise NS Act Total, and you remove the filter context at the year summary level (the .383 value), you are in essence removing the filter. That's why I'm speculating that it could be a filter context issue.

    • JC3's avatar
      JC3
      Frequent Visitor

      Sounds like on right track, b/c I've noticed that depending on the data range I use to review table, the summed value changes e.g. if I just look at Sept-Dec values, it just sums those. 

       

      The way the data goes together: 

      [NS Act Total] = sum([NS Act]) where [NS Act] is a column of sales data for a variety of countries, by month. 

      [NS Proj Total] is created same way from another column. 

       

      There's a separate date table that's associated with the fact table. 

       

      If using the IF statement in this way is the problem, interested in a solution that would combine these two measures.