DAX conditional sum

前端 未结 1 2031
温柔的废话
温柔的废话 2021-01-28 14:16

How to construct a DAX measure which returns sum of either A or B. The logic is take B if A is empty. So expected results looks like this:

+---+---+----------+
|         


        
1条回答
  •  余生分开走
    2021-01-28 15:09

    I'd recommend using a SUMX iterator in this case.

    Measure = SUMX ( tab, IF ( ISBLANK ( tab[A] ), tab[B], tab[A] ) )
    

    You might be able to do the following as well:

    Measure = 
        CALCULATE ( SUM ( tab[A] ) ) +
        CALCULATE ( SUM ( tab[B] ),
            FILTER ( tab, ISBLANK( tab[A] ) )
        ) 
    

    0 讨论(0)
提交回复
热议问题