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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
TimothyJames
Frequent Visitor

Dynamically Merging Different Tables - Sub querying

Hello, we have a django web application that is utilizing content types and generic foreign keys, and if you're unfamiliar with that, essentially. Its a referential lookup on other tables. 

 

So in this example, I have merged together a few tables to represent this table structure, only showing relevant columns for complexities sake.

 

lookuptable (first row is formulas)

 

formulas being applied  merged in from django_contenttype using utilized_model_idmerged in from django_contenttype using utilized_model_idconcat("public ", app_label, "_", model)
idutilized_model_object_idutilized_model_idapp_labelmodellookuptable
14112aqeidareapublic aqe_idarea
25112aqeidareapublic aqe_idarea
36112aqeidareapublic aqe_idarea
47112aqeidareapublic aqe_idarea
58112aqeidareapublic aqe_idarea
36911354corelookuplookupcheckoutsectionpublic corelookup_lookupcheckoutsection

 

 

 

django_contenttype

idapp_labelmodel
1biqarea
2biqbuilding
112aqeidarea
354corelookuplookupcheckoutsection

 

 

aqe_idarea

idareanamearea rollup
4TM northtransmissions
5TM Southtransmissions
6TM north2transmissions
7tm south2transmissions
8TM south5transmissions

 

 

What I want to do is merge into the lookuptable the dynamic lookup from the related django_contenttypes with a subquery.

 

The resulting table would look like lookuptable, but it would have aqe_idarea.areaname and aqe_idarea.area rollup on rows 1 - 5, but then it would do the lookup for corelookup_lookupcheckoutsection.[column N's name] on row 3691.

 

 

How do I do this in the advanced query editor to essentially sub query for each row?

1 REPLY 1
AlexisOlson
Super User
Super User

I'm unsure that I'm understanding correctly. Can you explicitly show what the final result should look like for the given example?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.