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
mnarmeen
Helper I
Helper I

All function with condition

Hello,

 

I have a date filter which I want to ignore on one column of the table, I cant use edit visualization for the whole table as other columns depends on date.

 

I want to show total sum of bottles a user owns which is irrespective of the date. But the problem is it interacts with date filter and only shows bottles which are bought by the user in selected month. So far I have tried using the following formula for making a calculated column, but it doesn't give desired result.

 

TotalSale=CALCULATE(SUM(entries[itemQty]),FILTER(ALL(entries),entries[itemCode]="19LBottle"))

 

I have also used another method to solve it,l but still it doesnot provide me with correct results

 

Column1=CALCULATE(SUM(entries[itemQty]),entries[itemCode]="19LBottle"))

Column2=CALCULATE(SUM(entries[itemQty]),ALL(Column1)))

 

 

Any help would be appreciated.

 

1 ACCEPTED SOLUTION

Hi @mnarmeen,

 

As a good practice I ussually do a Calendar table to filter out my reports, however on your measure you are using all in the full table you need to only do the ALL for the date column you can try to make this change to your measure:

 

TotalSale =
CALCULATE (
    SUM ( entries[itemQty] ),
    FILTER ( ALL ( entries[Date] ), entries[itemCode] = "19LBottle" )
)

 

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

9 REPLIES 9
MFelix
Super User
Super User

Hi @mnarmeen,

 

You need to calculate this as a measure and not as a column, if you make your first formula in a measure and add it to your visuals should work, the ALL is a formula that is based on context so when you used it in a column the context is the row itself so no "filters" are applied but when you add that column to your reports the filter then kicks in and filter out the values that you also don't want.

 

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



And if I use this, it show me all the Qty without filtering it on the basis of customerid, which is present in the table

 

TotalSale=CALCULATE(SUM(entries[itemQty]),FILTER(all(entries),entries[itemCode]="19LBottle"))

Is the date filter on the same table or on a Calendar table?

 

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



Date filter is on the same table. 

Hi @mnarmeen,

 

As a good practice I ussually do a Calendar table to filter out my reports, however on your measure you are using all in the full table you need to only do the ALL for the date column you can try to make this change to your measure:

 

TotalSale =
CALCULATE (
    SUM ( entries[itemQty] ),
    FILTER ( ALL ( entries[Date] ), entries[itemCode] = "19LBottle" )
)

 

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



Thankyou @MFelix,

However, I get the following error "A single value for column 'itemCode' in table 'entries' cannot be determined. This can happen when a measure formula refers to a column that contains many values"

Try this change to your code:

 

TotalSale =
CALCULATE (
    SUM ( entries[itemQty] ),
    FILTER ( ALL ( entries[Date] ), MAX(entries[itemCode]) = "19LBottle" )
)

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



Got it , Thanks alot !

 

Thankyou @MFelix , 

 

Ive made this a measure in enteries table , but still it wont show me the values. It only shows me values when I choose ALL from my date slicer.

 

 

TotalSale=CALCULATE(SUM(entries[itemQty]),FILTER((entries),entries[itemCode]="19LBottle"))

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.