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
sabilahmed
Resolver I
Resolver I

Calculated column from one table to another table

Hello,

 

I desperately need help with the following problem.

 

I have a calculated column in table "Config" which counts the number of instances per IV_Product_RecID (as there are "many" rows with multiple instances of IV_Product_RecID):

Count_IV_Product_RecID =

    CALCULATE(

        COUNT(Config[IV_Product_RecID]

            ),

            FILTER(

                Config,

                Config[IV_Product_RecID] = EARLIER(Config[IV_Product_RecID])

            )

    )

 

Then I have another table v_rpt_product with only "one" row per IV_Product_RecID. I have made sure there is a one-many relationship beween the two tables as depicted below:

 

sabilahmed_0-1645200212716.png

 

I need to add a calculated column in v_rpt_product telling me the number of times/ instances IV_Product_RecID shows up in the Config table.

 

I tried to "merge" the two tables so I could "expand" to return the calculated column from Config but this did not work as the merge feasture will not return the calculated column. Basically this would have worked in excel like a vlookup.

 

Please help me!

 

Thanks in advance,

S

1 ACCEPTED SOLUTION
sabilahmed
Resolver I
Resolver I

I've done it:

 

Created a calculated column in v_rpt_product:

 

Count_IV_Product_RecID = COUNTROWS(RELATEDTABLE(Config))

View solution in original post

3 REPLIES 3
sabilahmed
Resolver I
Resolver I

I've done it:

 

Created a calculated column in v_rpt_product:

 

Count_IV_Product_RecID = COUNTROWS(RELATEDTABLE(Config))
Anonymous
Not applicable

Have you tried merge queries in power query?

Yes - I mentioned that above, but it didn't work. Due to the nature of the calculation it doesn't appear as one of the columns to expand in the merge.

 

I'm thinking a better way to solve this issue is if I rephrase my questions to this:

How can I create a calculated column in my Config table to return the count of IV_Product_RecID from v_rpt_product table?

 

Remember:

Config has MANY ID's

v_rpt_product has UNIQUE ID's per row

 

Therefore this is a ONE-MANY relationship.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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