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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jthake-msft
Employee
Employee

1 to many relationship - want to show top row foreign key as column

I have a scenario where I have a table with a 1 to many relationship

 

Questions

QuestionId - Title

 

QuestionsWorkloadId

QuestionID - WorkloadId - WorkloadAssignmentDate

 

In the Questions table, I would like to have a column added to show the workloadId for the row with the most recent WorkloadAssignmentDate.

 

I was looking into using something like 

CurrentWorkloadId = CALCULATE(TOPN(1,QuestionWorkloadAssignments, QuestionWorkloadAssignments[WorkloadId], ASC))
 
But I can't seem to work out how to get it to work . Could someone help me please?
1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @jthake-msft ,

 

try this:

 

MAXX(
    TOPN(
        1,

        RELATEDTABLE ( QuestionWorkloadAssignments),

        QuestionWorkloadAssignments[Date],

        ASC),
    QuestionWorkloadAssignments[workloadId] )

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
ImkeF
Super User
Super User

Hi @jthake-msft ,

 

try this:

 

MAXX(
    TOPN(
        1,

        RELATEDTABLE ( QuestionWorkloadAssignments),

        QuestionWorkloadAssignments[Date],

        ASC),
    QuestionWorkloadAssignments[workloadId] )

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thank you.

 

If the Workload table had a WorkloadName

 

Is there a way to output that in the column rather than the WorkloadId?

 

As I can't seem to add a relationship to this column to a table, so that I can create a chart that shows a breakdown of number of questions by Workload name 

Hi

I might be missing something here, but wouldn' t this work?:

 

MAXX(
    TOPN(
        1,

        RELATEDTABLE ( QuestionWorkloadAssignments),

        QuestionWorkloadAssignments[Date],

        ASC),
    QuestionWorkloadAssignments[Name] )

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

No the name of the workload is in the Workload table not the QuestionWorkloadAssignments table. In the formula, it can't resolve Workload[Name], I'm guessing because it isn't the related table. Although QuestionWorkloadAssignments does have a retionship with the Workload table.

 

Questions

QuestionId - Title

 

QuestionsWorkloadAssignments

QuestionID - WorkloadId - WorkloadAssignmentDate

 

Workload

WorkloadId - WorkloadName

 

 

What I did was create a new Column basically adding WorkloadName to the QuestionsworkloadAssignments table. And then used this in the Questions table for CurrentWorkloadName column based on your formula. Thank you!

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.