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
Anonymous
Not applicable

Dynamic formula based on corresponding column

Hi everyone,

 

I have the following formula:

United Measure =

VAR SelectedColumn = SELECTEDVALUE('C'[C])

 

Return SWITCH(SelectedColumn;

"C1"; SUMX('E&A';'E&A'[Hours]*RELATED('A&C'[C1]));

"C2"; SUMX('E&A';'E&A'[Hours]*RELATED('A&C'[C2]));

"C3"; SUMX('E&A';'E&A'[Hours]*RELATED('A&C'[C3]))

 

  • My goal is to fill the matrix at the bottom without repeating the line ("C1"; SUMX('E&A';'E&A'[Hours]*RELATED('A&C'[C1]));) for each single C's (about 100 columns).

 

As a quick run down, those are the table I am using:

 

Table 1: (List of A's)

A's

A1

A2

A3

...

A100

 

Table 2. (List of E's)

E's

E1

E2

E3

...

E100

 

Table 3. (List of C's)

C's

C1

C2

C3

...

C100

 

Table 4. (Relation between A's and each C's)

A's

C1

C2

C3

...

C100

A1

1

1

1

...

0

A2

0

1

1

...

1

A3

1

0

1

...

1

...

...

...

...

...

...

A100

1

1

0

...

1

 

Table 5. (Relation between A's and E's in hours)

E's

A's

Hours

E1

A1

3

E1

A2

2

E1

A3

5

E2

A1

1

E2

A100

7

E3

A1

3

E3

A3

4

E3

A100

2

...

 

 

E100

A2

1

 

End matrix:

E's

C1

C2

C3

...

C100

E1

8

 

 

 

 

E2

 

 

 

 

 

E3

 

 

 

 

 

...

 

 

 

 

 

E100

 

 

 

 

 

 

I hope this is understandable.

 

Best regards,

1 REPLY 1
parry2k
Super User
Super User

@Anonymous can you share sample pbix file with expected output and can look at it. It is bit hard to understand and reproduce the dataset from your post.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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 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.

Top Solution Authors