Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

Create a Calculated Table using a UNION that preserves all values in one table

I have two tables withe the same structure.

 

In one I have rows that I always want to include.  In the other I have a slicer based on this which the user can select the rows they are interested in.

 

I want to then have a table which is the UNION of the two tables.

 

I have tried using :   CalcTable = UNION ( 'Filtered Tabled', ALL( 'Static Table))

 

I then put a Table on the report page that displays the values from the CalcTable.   However it does not seem to include the static rows and only shows me the filtered rows.

 

What am I doing wrong here?

10 REPLIES 10
marej123
New Member

This is awesome!! Thank you!! @LivioLanzo 

v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @mcairney,

 

From your pbix, it seems that you have created the relationship like below. So when you  select the slicer based on Site Key from User Site table, it will show the filtered value.

 

relationship.png

 

I'm a little confused about your requirement, do you only want to get the all rows like below which won't be filtered  by the selection of the slicer.

Capture.PNG

 

If it is, you could delete the relationship between the table User Site and All Sites, but that slicer seems to be meaningless if you remove the relationship.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Cherry

 

The relationships were where I was also trying different options to find what works.

 

What I need is to have 2 sets of Sites and then combine them.  However only the rows from the "User Site" table can be filtered and the ones in the "Reference Site" table are all included.   The combined set should then filter the "Site Metrics" table and the final data set then used on the chart to show the "Reference Site" differently from the "User Site".

 

So as I select e.g. the value "Kof18" in the slicer, the final table should have the values "Par15", "Feb22" and "Kof18"

LivioLanzo
Solution Sage
Solution Sage

Hi @mcairney

 

are you able to post a sample dataset ?

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

 Here is a basic sample of what I'm trying to do   

Hello @mcairney

 

thanks for the file. You need to create a calculate table with this DAX Query:

 

You can download the file: https://1drv.ms/u/s!AiiWkkwHZChHj0R4TRtHxsgRDnct

 

UnionTable = 
UNION(
    ADDCOLUMNS( ALLNOBLANKROW('Reference Site'), "SourceTable", "ReferenceSite" ),
    ADDCOLUMNS( ALLNOBLANKROW('User Site'), "SourceTable", "UserSite" )
)

Do not relate it to any table. In the slicer, use the Key from the 'Site Metrics' table. Then add a table visual and add this measure as a visual filter = 1

 

Measure = 
CALCULATE(
    COUNTROWS( UnionTable ),
    TREATAS(
        UNION(
            CROSSJOIN( ALL( 'Site Metrics'[Site Key] ), {"ReferenceSite"} ),
            CROSSJOIN( VALUES( 'Site Metrics'[Site Key] ), {"UserSite"} )
        ),
        UnionTable[Site Key], UnionTable[SourceTable]
    )
)

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

@LivioLanzo I worked out where my version was going wrong.

 

However, now I need to look at extending this a bit further.   If I have more than 1 Metrics table, does this solution extend out to be able to appply the same filter across that?

 

Thanks

Hi @mcairney

 

it should be possible. What are you trying to do exactly?

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

@LivioLanzo  Assume that there is 2 additional tabl;es with a similar structure to Site Metrics  - lets call them Site Metrics2 and Site Metrics 3

 

Again they have relationships to Site Key and Region.

 

I want this slicer to also filter the values in those other tables.   I can mock this up if you need?

Hi @mcairney,

 

For your requirement, I have made a test. You could create the relationship like below.

 

relationship.PNG

 

Then the slicer of  Site Key and Region will filter the table Site Metrics2 and Site Metrics 3.

 

filtered by the slicer.png

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.