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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Muhammad_Ahsan
Frequent Visitor

How to reference a 1st virtual table column in 2nd virtual table column in dax table

Dear All,

 
Hope you are doing well.
I am creating a virtual table , in which i want to reference dax calculated column 1 in another dax expression in second dax calculated column. 
for e.g.
ALL_STUDENTS_LASTDATE_PERFORMANCE_v3 =
 CALCULATETABLE(
     DISTINCT(
         SELECTCOLUMNS(ALL_CLASSES_FOR_DAILY_REPORT, "Student_Name", ALL_CLASSES_FOR_DAILY_REPORT[STUDENT NAME],
         "Report_Date", MAX(ALL_CLASSES_FOR_DAILY_REPORT[Timestamp].[Date]),
         "Department", ALL_CLASSES_FOR_DAILY_REPORT[Department],"Current_Stage", RELATED('STUDENT MASTER'[Current Stage]) ,
         "Duration_From_Joining",
DATEDIFF((RELATED('STUDENT MASTER'[Joining Date])), max(ALL_CLASSES_FOR_DAILY_REPORT[Timestamp]), MONTH), "Hifz_Stage", 1 ,
    "Hifz_Stage_Reference",
 [Hifz_Stage]
(now this is first column [hifz_stage] defined above, now i want to use this column [hifz_stage] in second column as well ) how to achieve this ?
))  
   

 
I tried and it is giving following error.
Column reference.png
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Muhammad_Ahsan 

If you want to use the columns in the first virtual table in the second virtual table, you need to add some filter conditions, such as the same ID column in Table 1 and Table 2, and then go to Table 1 to find the value in the column, you can refer to the example.

I create a calculated table, the virtual table a is created, a flag column is added to a, and if the value > 6, it is assigned 1, otherwise it is 0. Then in the current table, reference the flag column in the virtual table to find the relevant value, and in the flag column that returns the value, you can use the Maxx() and filter() functions to combine.

Table 2 = var a=ADDCOLUMNS(GENERATESERIES(1,10,1),"Flag",IF([Value]>6,1,0))
 return ADDCOLUMNS({5,8,10},"Flags",MAXX(FILTER(a,[Value]=EARLIER([Value])),[Flag]))

Output

vxinruzhumsft_1-1690337274221.png

So for example, if you want to reference [Hifz_Stage] in the v1 table in the v2 table you are creating, you need to go to the v1 table to find it and then reference the column.

 

Best Regards!

Yolo Zhu

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

 

 

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Muhammad_Ahsan 

If you want to use the columns in the first virtual table in the second virtual table, you need to add some filter conditions, such as the same ID column in Table 1 and Table 2, and then go to Table 1 to find the value in the column, you can refer to the example.

I create a calculated table, the virtual table a is created, a flag column is added to a, and if the value > 6, it is assigned 1, otherwise it is 0. Then in the current table, reference the flag column in the virtual table to find the relevant value, and in the flag column that returns the value, you can use the Maxx() and filter() functions to combine.

Table 2 = var a=ADDCOLUMNS(GENERATESERIES(1,10,1),"Flag",IF([Value]>6,1,0))
 return ADDCOLUMNS({5,8,10},"Flags",MAXX(FILTER(a,[Value]=EARLIER([Value])),[Flag]))

Output

vxinruzhumsft_1-1690337274221.png

So for example, if you want to reference [Hifz_Stage] in the v1 table in the v2 table you are creating, you need to go to the v1 table to find it and then reference the column.

 

Best Regards!

Yolo Zhu

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

 

 

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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