Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

CASE SUM from SQL SERVER to Power BI

How to bring this query from SQL SERVER to Power BI. I have to bring this query to a measure in Power BI and I don' t understand how to arrasnge this one. Can you help me? SQL SERVER: sum(CASE WH...
  • Alex87's avatar
    2 years ago

    Hello,

    Try this:

     

     

    Colli = 
    VAR _Total = SUM(anama[ppcoll]) 
    VAR _Quantity = SUM(vendite[quantita]) 
    
    VAR _Result = 
    SWITCH( 
       TRUE(), 
          ISBLANK(_Total), 0,
          _Total <> 0, DIVIDE(_Quantity, _Total), 
       0) 
    
    RETURN _Result

    If it answers your needs, please mark my reply as the solution