2017-11-17 249 views
0

如何在TSQL中執行以下DAX表達式?將DAX開關邏輯轉換爲TSQL

Channel Mapping: = 
    SWITCH(
     TRUE(), 
      NOT (ISERROR (SEARCH ("ChannelOne", ChannelFact[ChannelName]))), "C1", 
      NOT (ISERROR (SEARCH ("ChannelTwo", ChannelFact[ChannelName]))), "C2", 
      NOT (ISERROR (SEARCH ("Channel2", ChannelFact[ChannelName]))), "C2", 

     "Not Mapped" 
) 

我認爲它需要CASE邏輯,但不確定如何放在一起。

回答

1
SELECT CASE ChannelName WHEN "ChannelOne" THEN "C1" 
         WHEN "ChannelTwo" THEN "C2" 
         WHEN "Channel2" THEN "C2" 
       ELSE "Not Mapped" END AS "Channel Mapping" 
FROM 
ChannelFact 

謝謝。

+0

謝謝satishcse! –

+0

完美的作品!感謝Satishcse! –

+0

總是HTH!雖然我不知道DAX :) – satishcse