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
PaulMac
Helper IV
Helper IV

Sum the "Amount" column only if "Date" column is NOT blank

As the title states i need to sum the "Amount" column but only if there is a date in the "Date" column.

 

I am trying to create a new DAX measure but have hit a roadblock.

 

I currently have:

=SUM(Table[Amount Column])

 

I am still a complete novice with DAX and am starting to get frustrated as this seems like such a simple task.

 

I look forward to any help you are willing to give in the hopes of finding a solution to my problem.

1 ACCEPTED SOLUTION

Hi @PaulMac,

 

The issue is in the middle of your measure the measure should look like this

 

CALCULATE (
    SUM ( All_Complaints[Amount of Compensation Paid (£)] ),
    FILTER (
        ALL ( All_Complaints[Date Compensation Was Paid] ),
        All_Complaints[Date Compensation was Paid] <> BLANK ()
    )
)

Previous measure marked in bold the incorrect bracket:

 

=CALCULATE (
              SUM( All_Complaints[Amount of Compensation Paid (£)] ),
              FILTER ( All ( All_Complaints[Date Compensation Was Paid] ), All_Complaints[Date Compensation was Paid]
)  <-this is the incorrect bracket

 <> BLANK () )
)

 

 

Regards

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

12 REPLIES 12
MFelix
Super User
Super User

Hi @PaulMac,

 

When you are refering to make the sum of the Amount, what do you mean exactly, you want to return  the value of the Amount if there is no date, or do you want to sum the whole column values when the date is not null.

 

 

Based on the dax formula you have you should use a calculated measure:

 

Measure =
CALCULATE (
    SUM ( Table1[Amount] );
    FILTER ( ALL ( Table1[Date] ); Table1[Date] <> BLANK () )
)

 

 

Regards,

MFelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Sorry @MFelix but i get this error

 

 

This formula is invalid or incomplete: 'The expression is not valid or appears to be incomplete. Please review and correct the expression.
The syntax for ')' is incorrect. (DAX(

 

=CALCULATE (
              SUM( All_Complaints[Amount of Compensation Paid (£)] ),
              FILTER ( All ( All_Complaints[Date Compensation Was Paid] ), All_Complaints[Date Compensation was Paid]) <> BLANK () )
)

Any thoughts on how I can proceed?

Hi @PaulMac,

 

Remove the last  ) from your formula, you have to many brackets.

 

While copy pasting something went wrong and you have  the addtional one Smiley Happy

 

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix

 

I removed the last bracket as per your advice but now I get the following error:

 

This formula is invalid or incomplete: 'Calculation error in measure 'All_Complaints'[Compensation Paid]: A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.'.

 

Any other ideas?

Hi @PaulMac,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @PaulMac,

 

The issue is in the middle of your measure the measure should look like this

 

CALCULATE (
    SUM ( All_Complaints[Amount of Compensation Paid (£)] ),
    FILTER (
        ALL ( All_Complaints[Date Compensation Was Paid] ),
        All_Complaints[Date Compensation was Paid] <> BLANK ()
    )
)

Previous measure marked in bold the incorrect bracket:

 

=CALCULATE (
              SUM( All_Complaints[Amount of Compensation Paid (£)] ),
              FILTER ( All ( All_Complaints[Date Compensation Was Paid] ), All_Complaints[Date Compensation was Paid]
)  <-this is the incorrect bracket

 <> BLANK () )
)

 

 

Regards

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Thanks for the reply @MFelix but I get the error message

 

The syntax for ';' is incorrect. 

 

Smiley Sad

 

I subbed the ; for , but still get an error

 

I am doing this on an Excel Pivot Table and not I Power BI if that makes any difference.

Hi @PaulMac,

 

That as to do with regional settings, replace the ";" by "," on the measure.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hmmmm, I did substitue the ; for , but still get an error unfortunately

 

As I mentioned, I doing this measure on a pivot table in Excel instead of Power BI if that makes any difference.

The formula is the same for both instances


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix

 

Thanks for your reply.

 

Yes, I want to sum the whole column values when the date is not null.

 

I have amended my first post as I am working with DAX and not M as I originally stated, see original post for the measure I have so far

 

Thanks

Paul

Just adjust my response based on your adjustment of the first post.

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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.