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

Create a SUM measure that sums conditionally (based on a value in another column)

Hello,

 

I'm new in PowerBI so looking for some assist. Let's say I've table called DATA :

 

GL Account no.Amount
6001110-2663,67
5008310-2434,96
5008110-1530
6001310-1080
6001152-243,34
6008152-56,66
6008152243,34
6008110616,33
6008310945
60083101080
60011101530
60081102663,67
6001110-62
6001110-50,66
600111040
600111050,66
600111050,66
600111062
6001310135
5001310-550
6008110-120
5001110-6
5001110-1466
5001310-64
8001310-63,72

 

 

And another table called GL_COSTS

 

GL Account no.

6001110
6001152
6001310

 

 

How can I sum values only for those GL Account no. which are in GL_COSTS table?

 

Thanks in advance!

 

 

 

1 ACCEPTED SOLUTION

Hi samto22,

 

Have you built a relationship between the two tables? Click "manage relationship" and set many-to-one relationship as below:

3.PNG 

Then you can create a measure using both of DAX formula like below:

Measure = 
CALCULATE (
    SUM ( Data[Amount] ),
    FILTER(DATA, DATA[GL Account no.] = RELATED(GL_COSTS[GL Account no.])
))

Measure = 
CALCULATE (
    SUM ( Data[Amount] ),
    GL_COSTS
)

2.PNG捕获.PNG  

 

Regards,

Jimmy Tao

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

If the two tables are related by Account No. you can use

 

Measure =
CALCULATE ( SUM ( Data[Amount] ), GL_COSTS )

 

if the tables are not related...you can try

 

Measure 2 =
CALCULATE (
    SUM ( Data[Amount] ),
    FILTER ( Data, Data[GL Account no.] IN VALUES ( GL_COSTS[GL Account No.] ) )
)

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

These two tables are related by Account No. so I used your first formula but unfortunately it does not give any result 😞

 

I created this measure in DATA table, is it ok?

Hi samto22,

 

Have you built a relationship between the two tables? Click "manage relationship" and set many-to-one relationship as below:

3.PNG 

Then you can create a measure using both of DAX formula like below:

Measure = 
CALCULATE (
    SUM ( Data[Amount] ),
    FILTER(DATA, DATA[GL Account no.] = RELATED(GL_COSTS[GL Account no.])
))

Measure = 
CALCULATE (
    SUM ( Data[Amount] ),
    GL_COSTS
)

2.PNG捕获.PNG  

 

Regards,

Jimmy Tao

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.