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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Calculated tables and virtual tables not producing the same output

Hi,

 

This is my first time posting a request on the forum so apologies if I get anything wrong in terms of process or formatting.

 

I have a dataset describing documents that have unique ID numbers and associated metadata (a publication year and document category). Each document is authored by one or more teams. The source table I'm working from is an unpivoted form of this data:

jennywool_0-1632920210621.png

What I'm trying to do is produce a heatmap table, with the team names down the rows and column headings, where the values in the table are the number of documents that are co-authored between the teams. The diagonal terms will obviously just be the count of documents authored by that one team. 

 

I can produce the desired result by creating separate calculated tables for each team, in which I use an intersect command to return all the rows in the original 'Data' table which have documen IDs where the team in question is an author:

 

 

Team A CT =
CALCULATETABLE (
    'Data',
    INTERSECT (
        VALUES ( 'Data'[ID] ),
        SELECTCOLUMNS ( FILTER ( 'Data', 'Data'[Team] = "Team A" ), "ID", 'Data'[ID] )
    )
)

 

 

 

If I create a table and set the distinct count of the ID to display I get the result that I expect:

jennywool_1-1632920594878.png

However, since these are calculated tables they won't respond to any filters, and what I'd really like is to be able to filter on the teams (so table rows), publication year and document categories. 

 

So I tried to replicate the process by creating virtual tables within measures, for example:

 

 

Team A Measure =
VAR _idlist =
    SELECTCOLUMNS ( FILTER ( 'Data', 'Data'[Team] = "Team A" ), "ID", 'Data'[ID] )
VAR _teamtable =
    CALCULATETABLE ( 'Data', INTERSECT ( VALUES ( 'Data'[ID] ), _idlist ) )
RETURN
    COUNTX ( _teamtable, [ID] )

 

 

But when I display this in a table, I only see the diagonal terms and all the off diagonals evaluate as blank:

jennywool_2-1632921695265.png

In this case, the row totals are equal to the number of rows within the individual calculated tables, which is what you would get in the previous visual if I had set the values as count of ID instead of distinct count of ID.

 

The demo pbix file I've created for this is stored here: Pbix demo file 

 

I'm currently going round in circles with this, so would appreciate help in understading what is going here.

 

Many thanks!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Not sure if you're overthinking this.  See attached an alternative implementation.  You'd still have to figure out the filter mechanics.

lbendlin_0-1633202211908.png

 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Not sure if you're overthinking this.  See attached an alternative implementation.  You'd still have to figure out the filter mechanics.

lbendlin_0-1633202211908.png

 

Anonymous
Not applicable

That does indeed work 😆

 

Thanks

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.