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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.