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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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