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
MTOnet
Helper III
Helper III

Show All Related Records Between Tables when One Table is Filtered to Show Most Recent Records

How would I go about showing all related records between two tables, when one of the tables has a Calcualted Column to determine the most recent occurence of a record?  I am trying to create two Table Visualizations that filter each other when a record is selected in one of them, but not coming up with a goo solution.

Source1

IDNameOptionRelated Type1Related Type2StatusMost Recent
1Test Name1ABStatus10
2Test Name2A Status11
3Test Name1A Status21
4Dummy Name1CDStatus31
5Placeholder1EFStatus20
6Placeholder1EGStatus31
7New Name1H Status20
8New Name1HBStatus11
9Another Name1JK,LStatus21

Source2

IDNameTypeStatus
ATest NameType1Status1
BSome NameType2Status4
CDummy NameType1Status5
DRelated NameType2Status1
EPlaceholderType1Status1
FAnother NameType2Status4
GMore NameType2Status6
HNew NameType1Status5
INamelessType2Status5
JAnother NameType1Status4
KSample NameType2Status5
LFinal NameType2Status6

This data is displyed in table visualizations

Table1 - with visualization level filter Most Recent = 1, as I only need to see one record in the table for each Name/Option pair

NameOptionStatus
Test Name1Status2
Test Name2Status2
Dummy Name1Status3
Placeholder1Status3
New Name1Status1
Another Name1Status2

Table2 - with visualization level filter Type = Type2

IDNameStatus
BSome NameStatus4
DRelated NameStatus1
FAnother NameStatus4
GMore NameStatus6
INamelessStatus5
KSample NameStatus5
LFinal NameStatus6

The interations I am trying to setup

  • clicking on Test Name/1 in Table 1, results in1 record (ID B) in Table 2
  • clicking on Test Name/2 in Table 1, results in zero records in Table 2
  • clicking on Placeholder/1 in Table 1, results in two records (F & G) in Table 2
  • clicking on Another Name/1 in Table 1, results in two records (K & L) in Table 2 (with the realization I may need to split the comma seperated values into individual rows)
  • clicking on ID B in Table 2, results in two records (Test Name/1 & New Name/1) in Table 1
  • clicking on ID F in Table 2, results in one record (Placeholder/1) in Table 1

Creating a Bridge table between the two Sources did not create the results I am looking for.  When doing this, I only get results if the Related Type2 item is on the record that is tagged as being the most recent one.  I'm sure there is a way to do this such that PowerBI does more of the work.  I know I could generate this solution through a series of measures that calculate whether the record should be displayed or not and then updating the visual level filter accordingly.  Doing it in this way creates maintenace issues and also feels like I am forcing the issue while not using Power BI properly and I feel there must be a better solution.

Thank you for your assistance

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @MTOnet ,

 

I don't quite understand the logic. I wonder if your description is wrong.


@MTOnet wrote:

Source1

IDNameOptionRelated Type1Related Type2StatusMost Recent
1Test Name1ABStatus10
2Test Name2A Status11
3Test Name1A Status21
4Dummy Name1CDStatus31
5Placeholder1EFStatus20
6Placeholder1EGStatus31
7New Name1H Status20
8New Name1HBStatus11
9Another Name1JK,LStatus21

Source2

IDNameTypeStatus
ATest NameType1Status1
BSome NameType2Status4
CDummy NameType1Status5
DRelated NameType2Status1
EPlaceholderType1Status1
FAnother NameType2Status4
GMore NameType2Status6
HNew NameType1Status5
INamelessType2Status5
JAnother NameType1Status4
KSample NameType2Status5
LFinal NameType2Status6

This data is displyed in table visualizations

Table1 - with visualization level filter Most Recent = 1, as I only need to see one record in the table for each Name/Option pair

NameOptionStatus
Test Name1Status2
Test Name2Status2
Dummy Name1Status3
Placeholder1Status3
New Name1Status1
Another Name1Status2

Table2 - with visualization level filter Type = Type2

IDNameStatus
BSome NameStatus4
DRelated NameStatus1
FAnother NameStatus4
GMore NameStatus6
INamelessStatus5
KSample NameStatus5
LFinal NameStatus6

The interations I am trying to setup

  • clicking on Test Name/1 in Table 1, results in1 record (ID B) in Table 2
  • clicking on Test Name/2 in Table 1, results in zero records in Table 2
  • clicking on Placeholder/1 in Table 1, results in two records (F & G) in Table 2
  • clicking on Another Name/1 in Table 1, results in two records (K & L) in Table 2 (with the realization I may need to split the comma seperated values into individual rows)
  • clicking on ID B in Table 2, results in two records (Test Name/1 & New Name/1) in Table 1
  • clicking on ID F in Table 2, results in one record (Placeholder/1) in Table 1

 


 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@V-lianl-msft What are you not getting from my description, I'll try and elaborate as I believe I setup the scenario properly.  For the items in red, from Source1, that is the most recent record for that particular Name/Option pair, so that is what should be displayed in the Table visualization.  Then, if I select that record in Table1, Table2 should 1 record, since I want to see all records for that Name/Option pairing, no matter which one the current record is.

 

@Greg_Deckler Thanks for the link.  Reading what you wrote in that post actually shows I was thinking of doing this in the best way.  I thought maybe I was missing something and there would be a more elegant solution.  Maybe I read over your post before and had that in the back of mind while thinking this through.

 

As it perstains to the current situation, I'm having difficulty getting the measure to produce the results I want.  I'm using the TREATAS function since I have two unrelated tables and I'm using SUMMARIZE to get only the Relate Type 2 items from Source 1.  I would think I could use this to count how many times a record in Source 2 shows for each Related Type 2.  However, I keep getting a blank table when I select a record in Table 1

 

CALCULATE(
    COUNTROWS('Source2'),
    TREATAS(
        SUMMARIZE(
            Source1,
            Source1[Related Type 2]),
        'Source2'[Id]))

Any suggestions on how I can get a value to return to my measure on Table 2 so that I can then use a Table level visual?

Greg_Deckler
Super User
Super User

@MTOnet - It sounds like you need to create a Complex Selector, here is an example - https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Complex-Selector/m-p/1116633#M534


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.