Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Filters do not apply on UNION Tables

Hi guys,

 

I'm trying to join two tables with the same columns. I want to use the new table to show the datas from the two initial tables but i want to apply a filter on one of the column of one of the two tables.

 

My problem is that the UNION table is not affected by the filter on the initial table.

 

Can I solve that ?

  • Hey Anonymous,

     

    I'm not completely sure what you're trying to do, but I'm rifht and you have everything else down and still want to differentiate after the UNION, it's easy:
    Create a column in both before the UNION, with the same name, and just fill that column with tablename or 1 & 0 or anything that after the union will have two values. (Like [TableName] = "xyz" in the first, and [TableName] = "abc" in the second)

    Afterwards, when filtering, you could just always apply an extra clause with the [TableName] value.

    :)

4 Replies

  • Smauro's avatar
    Smauro
    Icon for Solution Sage rankSolution Sage

    Hey Anonymous,

     

    I'm not completely sure what you're trying to do, but I'm rifht and you have everything else down and still want to differentiate after the UNION, it's easy:
    Create a column in both before the UNION, with the same name, and just fill that column with tablename or 1 & 0 or anything that after the union will have two values. (Like [TableName] = "xyz" in the first, and [TableName] = "abc" in the second)

    Afterwards, when filtering, you could just always apply an extra clause with the [TableName] value.

    :)

    • Anonymous's avatar
      Anonymous
      Not applicable

      I'll try to be more clear :)

       

      My UNION is made on two tables, both contains text news :

       

      • One contains national news, with the "national" value on one of its column,
      • the other one contains local news, with the city name value on one of its column.

       

      The result of the UNION is one table. On one column there is either the "National" value, either a city name.

       

      On my report i have a filter that filters the local news table with the city name so I wanted the UNION table to display the national news and the local news based on the city name selected on my filter, but the filter doesnt seem to filter the result table even if it's filtering the source table...

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi,

         

        Did you ever get a solution to this please?

         

        I'm trying to do exactly the same thing you describe and I'm facing the same issue.

         

        Thanks.

  • Hi Anonymous

    Do you mean you created a calculated table using the UNION function?

    Once a calculated table is created, it has no lineage to any existing tables in the model, and you would need to create a relationship with the table where you are appling filters for those filters to have any effect.

     

    If the UNION function is being used as part of a measure however, lineage is retained where possible for each column separately, so filters could still have effect during the evaluation of the measure.