Ssrs

使開關在 SSRS 中工作

  • February 8, 2018

我試圖讓我的報告根據條件顯示不同的顏色單元格。這是我目前的程式碼:

=Switch(Fields!DaysToExpiration.Value > 31, "Green",  
       Fields!User_Certification_Status.Value = 8, "Firebrick”,
       Fields!User_Certification_Status.Value = 13, “Orange”,
       Fields!User_Certification_Status.Value = 11, “Orange”,
       Fields!User_Certification_Status.Value = 10, “Orange”,
       Fields!User_Certification_Status.Value = 12, “Orange”,
       Fields!DaysToExpiration.Value <= 30, "Yellow", 
       1=1, "Gray")

所以,我的問題在於程式碼的最後一部分。我使用的是矩陣視圖,這意味著有些單元格沒有數據。SSRS 將這些視為具有價值(我假設為 0)。這意味著所有空白的都會自動變成黃色,而不是灰色。我怎樣才能解決這個問題?謝謝。

是的,SSRS 處理空/空值可能有點麻煩。嘗試在黃色選項之前添加一個明確的 isnothing() :

=Switch(Fields!DaysToExpiration.Value > 31, "Green",  
   Fields!User_Certification_Status.Value = 8, "Firebrick”,
   Fields!User_Certification_Status.Value = 13, “Orange”,
   Fields!User_Certification_Status.Value = 11, “Orange”,
   Fields!User_Certification_Status.Value = 10, “Orange”,
   Fields!User_Certification_Status.Value = 12, “Orange”,
   IsNothing(Fields!DaysToExpiration.Value), "Gray",
   Fields!DaysToExpiration.Value <= 30, "Yellow", 
   1=1, "Gray")

引用自:https://dba.stackexchange.com/questions/197417