Forum Discussion
[Direct Query] how to create calculated column in 1 table based on filtered value on another table?
Hello all,
I'm using direct query mode for these two tables, so I can't use Powerquery in this case.
MISSION_HEADER and MISSION_DATA
these two have a many to one relationship between column GKEY and HEADER_GKEY.
I want to create a calculated column in the MISSION_HEADER table
I had found a solution
if you use the average function from the Fileds panel, it will average the total.
in order to average some transactions by filtering certain values, you have to use the AVERAGE function.
first, create the calculated column of two times to get the differences.
Turn Time-Mins = (MISSION_HEADER[Exit_Time]-MISSION_HEADER[ENTERED_YARD])*24*60then create a measure to average the transaction by filteringRE AVG Turn time = calculate(average(MISSION_HEADER[Turn Time-Mins]),filter(MISSION_DATA,MISSION_DATA[N4_MISSION_TYPE]="RE"))
5 Replies
- v-xicaiCommunity Support
Hi yfeng0 ,
Based on having create relationship between the two tables, and change the Cross filter direction of the relationship from Single to Both , you can create column like DAX below.
Turn Time-Mins = CALCULATE(MISSION_HEADER[Exit_Time]-MISSION_HEADER[ENTERED_TIME], FILTER(MISSION_DATA, MISSION_DATA[HEADER_GKEY]= MISSION_HEADER[GKEY] && MISSON_DATA[N4_MISSION_TYPE] = "RE"))Best Regards,
Amy
Community Support Team _ Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.