Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
10 years ago
Solved

IF Statement - Power BI Desktop

Hi everyone,

 

 

 I have a simple question and wantes some assitance. I have two columns (Reference Status and Date) in my dataset and wanted to create a simply IF statement. I want the IF statement to be "IF Reference Status = No, then display Date, otherwise display blank".

 

 Do I have to create a Custom Column for this IF Statement? Any help would be sincerely apprecated as I am new to Power BI.

  • Anonymous if you want to do this in Table View (after you've imported your Data) you use DAX like so

     

    DAX => New Column = IF ( [Reference Status]="No", [Date], BLANK() )

     

    if you want to do this during import in the Query Editor (just follow the picture)

    Give the Column a Name and the conditions - the Query Editor will genetrate the column in M which is

    M => if [Reference Status] = "No" then [Date] else ""

     

5 Replies

  • Sean's avatar
    Sean
    Community Champion

    Anonymous if you want to do this in Table View (after you've imported your Data) you use DAX like so

     

    DAX => New Column = IF ( [Reference Status]="No", [Date], BLANK() )

     

    if you want to do this during import in the Query Editor (just follow the picture)

    Give the Column a Name and the conditions - the Query Editor will genetrate the column in M which is

    M => if [Reference Status] = "No" then [Date] else ""

     

    • hodges914's avatar
      hodges914
      Regular Visitor

      Is there a way to create an IF statement based on the value of another table? For example, IF "Blah Table" = a value in "Blah Blah table" then return the value of "Compliant"...

       

      Basically trying to have a column that says whether or not an application's version is "In Compliance"... but I want the unit, that is being measured, to be a separate table that is kept updated on its own.

       

      Sorry if this makes no sense at all.... I will try my best to better explain myself if necessary.

       

      I was able to get the IF statement working, if I manually entered the version, but I would like to get the version from another table, due to the fact that this is an application that has several modules that have to be kept updated on a regular basis.

       

      If I can enter my values into a separate table and have that be my 'control' for the IF statement "true" portion, that would be amazing.

    • msalam's avatar
      msalam
      Frequent Visitor

      I'm receiving this error in my DAX query on calculated column as follows:

       

      Column = IF(Reading[ServiceId]=1, Reading[Value] , "On")

       

      ERROR:

      Function 'IF' is not allowed as part of calculated column DAX expressions on DirectQuery models

       

      Any Idea why i'm receiving that error?

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for this..... Worked like a charm. Sincerely appricate it.