2016-11-28 96 views
-1

我想重新創建一個嵌套的if語句,我在Excel中創建一個水晶報表公式。我試圖自己創建公式,並認爲我已經想通了,直到我查看了原始數據,並且看到Crystal和Excel之間的計算已經關閉,儘管原始數據完全相同。我已經在這裏和其他網站檢查了電路板,並且找不到像我這樣的初學者可以遵循的解決方案。我想要做的是根據具體問題調整公式的評分計算。我的兩個問題的得分不同於數據中的其他問題。在Crystal Reports中重新創建一個嵌套的if語句

這裏是我在Excel中的:

=IF(T4="How many calls have you taken on this product since your  
trainin",6,IF(T4="Did you experience any problems that your training did 
not prepa",IF(U4=1,0,6),(7-U4))) 

以下是我想出了在Crystal:

if {Command.Question_PK} = "55D0D569-7653-4553-B9C5-F858C5D318F9" Then 6 
Else if {Command.Question_PK} = "15948F36-E536-4C11-834A-BB5035754024" 
then if {Command.answer} = 1 Then 0 Else 6 
Else 7 - {Command.answer} 

望着數據集,看來水晶是不執行第一個if語句基本上是自動將該特定問題的得分自動調整爲6,無論回答者給出了什麼答案。

如何才能讓我的計算與我在Excel中獲得的數據完全相同?

+1

取出'excel'標記爲問題與修復問題公式無關。 –

回答

0

我不知道你是如何實現你的輸入。所以我只是寫了完全相同的算法,你有什麼在Excel中的C#。如果你在Visual Studio中創建控制檯應用程序並運行它,你可以看到它是如何工作的。

using System; 

class Program 
{ 
static void Main(string[] args) 
{ 
    int result = 0; 
    int U4; 
    string T4; 
    string statement1 = "How many calls have you taken on this product since your trainin?"; 
    string statement2 = "Did you experience any problems that your training did not prepa"; 

    Console.WriteLine("Please type value of T4"); 
    T4 = Console.ReadLine(); 
    Console.WriteLine("Please type value of U4"); 
    U4 = int.Parse(Console.ReadLine()); 

    if (T4 == statement1) 
    { 
     result = 6; 
    } 
    else 
    { 
     if(T4 == statement2) 
     { 
      if (U4 == 1) 
      { 
       result = 0; 
      } 
      else 
      { 
       result = 6; 
      } 
     } 
     else 
     { 
      result = 7 - U4; 
     } 
    } 
    Console.WriteLine("result is : "+result); 
    Console.ReadLine(); 
} 
} 
+0

謝謝你馬修。我能夠將你把代碼分解成我自己的公式並找到並解決問題的方式。再次感謝你。 –