Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Adding a condition in distinct union function

Hi everybody,

I am new in Power Bi & appreciate if anyone help me here:

I want to union the codes in 3 seperate tables and set the below formula which works correctly. 

 

Maintenance WO =  DISTINCT(union(FILTER(distinct(' Employee Hours'[Code]),'Employee Hours'[Code]<>""),FILTER(distinct(' Asset Hours'[Code]),'Asset Hours'[Code]<>"")))

 

Now, I want to add another condition for each table:

 

 

Simply, I just want to union the codes of two below tables if in employee table, crew type be MGMT and in Asset table, the crew type be Maint. Off course, empty codes must not be considered.

No idea what to do. your help would be highly appreciated.

 

 

  • Hi Anonymous,

     

    It works in my test. Did you make any changes?

    Adding_a_condition_in_distinct_union_function

     

    Best Regards,

    Dale

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    no one has any idea?

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi Anonymous,

     

    You almost got there. Try the formula below, please.

    Table =
    DISTINCT (
        UNION (
            CALCULATETABLE (
                VALUES ( Employee[Code] ),
                FILTER (
                    Employee,
                    ISBLANK ( Employee[Code] ) = FALSE ()
                        && Employee[Crew] = "MGMT"
                )
            ),
            CALCULATETABLE (
                VALUES ( Asset[Code] ),
                FILTER ( Asset, ISBLANK ( Asset[Code] ) = FALSE () && Asset[Crew] = "Maint" )
            )
        )
    )
    

    Best Regards,

    Dale

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi 

       

      • v-jiascu-msft's avatar
        v-jiascu-msft
        Microsoft Employee

        Hi Anonymous,

         

        It works in my test. Did you make any changes?

        Adding_a_condition_in_distinct_union_function

         

        Best Regards,

        Dale