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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
robg89
Regular Visitor

Urgent help needed for SUM function

I am trying to create a measure whereby I sum values from one table only if a record exists in another table. See below for example.

 

In this example, I want to sum values in the Sales table, according to Month but I only want to do it if the record in the Product column appears in the Products table (also ignoring blank product lines from Sales table).

 

Ideas please? 🙂

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @robg89 ,

If you want to create a new column:

SUM = 
    CALCULATE (
        SUM ( Sales[Value] ),
        FILTER (
            ALL ( Sales ),
            Sales[Month] = EARLIER ( Sales[Month] )
                && Sales[Prodect] <> BLANK ()
                &&  LOOKUPVALUE ( Project[Product], Project[Product], Sales[Prodect] ) <> BLANK ()
        )
    )

And if masure:

SUM1 = 
    CALCULATE (
        SUM ( Sales[Value] ),
        FILTER (
            ALL ( Sales ),
            Sales[Month] = MAX ( Sales[Month] )
                && Sales[Prodect] <> BLANK ()
                &&  LOOKUPVALUE ( Project[Product], Project[Product], Sales[Prodect] ) <> BLANK ()
        )
    )

Base table:

vluwangmsft_0-1640055035078.pngvluwangmsft_1-1640055043518.png

 

Output result:

vluwangmsft_2-1640055057542.png

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

 

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @robg89 ,

If you want to create a new column:

SUM = 
    CALCULATE (
        SUM ( Sales[Value] ),
        FILTER (
            ALL ( Sales ),
            Sales[Month] = EARLIER ( Sales[Month] )
                && Sales[Prodect] <> BLANK ()
                &&  LOOKUPVALUE ( Project[Product], Project[Product], Sales[Prodect] ) <> BLANK ()
        )
    )

And if masure:

SUM1 = 
    CALCULATE (
        SUM ( Sales[Value] ),
        FILTER (
            ALL ( Sales ),
            Sales[Month] = MAX ( Sales[Month] )
                && Sales[Prodect] <> BLANK ()
                &&  LOOKUPVALUE ( Project[Product], Project[Product], Sales[Prodect] ) <> BLANK ()
        )
    )

Base table:

vluwangmsft_0-1640055035078.pngvluwangmsft_1-1640055043518.png

 

Output result:

vluwangmsft_2-1640055057542.png

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

 

pranit828
Community Champion
Community Champion

Hi @robg89 

Can you please give the below measure a try

CALCULATE(SUM(Table1[value]),NOT(ISBLANK(TABLE1[Product])))




PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

It doesn't work I am afraid.. I assume you need to reference the Product table in the ISBLANK formula?

robg89
Regular Visitor

Picture1.png

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 MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.