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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ph
Helper I
Helper I

get only ONE sum result from table

Hi all,

 

I need help...I have following table

Document typeAmount
document 110
document 220
document 330
document 110
document 220
document 330

 

and I need get sum only for Document Type="document 2", so result should be this

Document typeAmount
document 1 
document 240
document 3 



I have this formula
measure= CALCULATE( SUM(Table[Amount);

ALL('Document Type'); -- I guess that ALL statement should be removed
Table[Document Type]="document 2"

but I getting this

Document typeAmount
140
240
340



Any idea WHY (please SIMPLE describe the logic if possible )?! Even when I do SUM only for document 2 context (filtrex context)

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

With the ALL-function, you are saying ignore all filters on the [document type]-column. So if you have a table with [document type] in it, the measure pays no respect to these. And since you after the ALL-function add a filter on [document type]="document 2", this is the only filter on [document type] you measure sees, so it will repeat that number for all document types.

 

You can change you dax code to this:

CALCULATE(SUM(Table[Amount]);FILTER(Table;Table[Document type]="document 2"))


The question you are asking conserns the filter context of the DAX language, which is an important concept in DAX. I highly recommend doing a DAX course, or buying one of the books which have published recently. It will make Power BI a more powerfull tool for you if you know the concepts of DAX.

View solution in original post

2 REPLIES 2
sturlaws
Resident Rockstar
Resident Rockstar

With the ALL-function, you are saying ignore all filters on the [document type]-column. So if you have a table with [document type] in it, the measure pays no respect to these. And since you after the ALL-function add a filter on [document type]="document 2", this is the only filter on [document type] you measure sees, so it will repeat that number for all document types.

 

You can change you dax code to this:

CALCULATE(SUM(Table[Amount]);FILTER(Table;Table[Document type]="document 2"))


The question you are asking conserns the filter context of the DAX language, which is an important concept in DAX. I highly recommend doing a DAX course, or buying one of the books which have published recently. It will make Power BI a more powerfull tool for you if you know the concepts of DAX.

Hi,

 

many thanks for response 🙂

 

I have a 'ultimate guide to dax' and studied contexts (but it is hard to use to context correctly, understanding of written formula is OK for me), but when I not use ALL in my formula I see the same value everywhere like with ALL function

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.