Forum Discussion

carlenb's avatar
carlenb
Icon for Advocate II rankAdvocate II
2 years ago
Solved

Sum based on other column values (IF, then...)

Hi,

 

I have the following data:

 

  • Sales data with Quantity, Total Value and Invoiced value 

Problem:

  • I want to create a measure that sums based on the below conditions:
  • If the value in column 'Quantity' or column 'Total value' is >0 then take the value from 'Invoiced value'  
  • If the value in column 'Quantity' or column 'Total value' is 0 then take the value from 'Total value'
  • If the value in column 'Invoiced value' is 'Not invoiced' then take the value from 'Total value'

How can I create this measure?

 

Table with data where the correct sum in this example would be 287. 

 

QuantityTotal valueInvoiced value
0611
01011
5015
01512
1123140
1235
266
097
4110
101
5505
3515
23Not invoiced
45Not invoiced
18Not invoiced
0915
2614
4112
5011
01511

 

 

  • I managed to solve this myself. Many thanks some_bih for helping along the way and asking the right questions! 

8 Replies

  • I managed to solve this myself. Many thanks some_bih for helping along the way and asking the right questions! 

  • some_bih's avatar
    some_bih
    Icon for Community Champion rankCommunity Champion

    Hi carlenb there is possible scenario 

    If the value in column 'Quantity' =0 and column 'Total value'>0 l(first row example)
    If the value in column 'Quantity' >0 and column 'Total value'=0 l(third row example)

     

    what to do?

    • carlenb's avatar
      carlenb
      Icon for Advocate II rankAdvocate II

      Hi some_bih 

       

      Thanks, well spotted! See below answers. You can also see the correct values for these scenarios in the screenshot in the thread start (Column E)

       

      If the value in column 'Quantity' =0 and column 'Total value'>0 l(first row example) If Quantity = 0 then it would be Total value even if Total value = 0 or >0
      If the value in column 'Quantity' >0 and column 'Total value'=0 l(third row example) If quantity > 0 then go for Total value even if Total value is = 0

      • some_bih's avatar
        some_bih
        Icon for Community Champion rankCommunity Champion

        Hi carlenb could you please once again check your conditions =0 and >0 could be Invoiced value and total value

  • Edited my latest post with a new table, since I need to consider also local currency.