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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to incorporate two columns from different unrelated tables into VALUES for SUMX of a measure?

Hi,

 

I am using a formula to create the SUM of a measure:
Total Underutilisation = IF(HASONEVALUE([name]), [Measure], SUMX(VALUES([name]), [Measure]))

I actually have two fields filtering the calculated Underutilisation, the name as well as the account.

These two columns are from two different and unrelated tables.


I was told I could use SUMMARIZE in the formula below:

=IF(HASONEVALUE([name]), [Measure], SUMX(SUMMARIZE([Table], [Column1], [Column2], "Custom"), [Custom]))

But my problem is that both the columns are from two different and unrelated tables, so I cannot use the ADDCOLUMNS and RELATED formulas either:

=IF(HASONEVALUE([name]), [Measure], SUMX(SUMMARIZE(ADDCOLUMNS([Table], "Custom", RELATED(Table2[Column2])), Table[Column], [Custom])))

 

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Have you already tried something like below?

 

NewMeasure =
IF (
    HASONEVALUE ( Table[Name] ),
    SUMX (
        CROSSJOIN ( VALUES ( Table1[Column1] )VALUES ( Table2[Column2] ) ),
        [Measure]
    )
)

 

You could also consider using TREATAS() to pass in a filter from the second table.


Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please correct me if I wrongly understand your question.

Without having relationships, and you need to create measure that shows corresponding result to the unrelated tables, you can try to use TREATAS function.

In this case, because there are two unrelated tables, I used two times of TREATAS in the measure.

 

you can find the link below that is the sample pbix file.

 

Value Total With TREATAS =
CALCULATE (
SUMX ( 'Table', 'Table'[Value] ),
TREATAS ( VALUES ( Names[Name] ), 'Table'[Name] ),
TREATAS ( VALUES ( Accounts[Account] ), 'Table'[Account] )
)
 
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster.

Picture6.png

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


mahoneypat
Employee
Employee

Have you already tried something like below?

 

NewMeasure =
IF (
    HASONEVALUE ( Table[Name] ),
    SUMX (
        CROSSJOIN ( VALUES ( Table1[Column1] )VALUES ( Table2[Column2] ) ),
        [Measure]
    )
)

 

You could also consider using TREATAS() to pass in a filter from the second table.


Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thank you, the CROSSJOIN worked perfectly for me!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors