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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

SUM with FILTER and ALLSELECTED

Having trouble with my DAX. 

Table contains different Account charges for different periods. 

Having a measure to calculate the amont only for the Sales and calculating the % for each account against the sales . 

But, the total is going wrong for the below measure. This is my first attempt with ALL & ALLSELECTED. 

 

Sales Total =
CALCULATE( SUM('Sales'[Amount] ),
FILTER( ALL('Sales'),'Sales'[Account] = "Sales"),
ALLSELECTED( 'Calendar'[FiscalYearNum] )
)
 

Pbix is  https://drive.google.com/file/d/19MJftynUVzV9BVfU3RuV0RLeKHSJ6K_G/view?usp=sharing

 

 

1 ACCEPTED SOLUTION

@Anonymous change sales total measure to this and everything will work

 

Sales Total = 
CALCULATE( SUM('Sales'[Amount] ),
    'Sales'[Account] = "Sales",
    ALLSELECTED ( Sales )
) 

 

parry2k_0-1593359704139.png

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi, it seems you want slicer filter to flow into your Total Sales, try it:

 

Sales Total 2:=CALCULATE( SUM('Sales'[Amount] ),
FILTER( ALL('Sales'[Account]),'Sales'[Account] = "Sales")
)

Anonymous
Not applicable

Thanks @Anonymous 

 

That works for the total with the below 

Sales Total 2:=CALCULATE( SUM('Sales'[Amount] ),
FILTER( ALL('Sales'[Account]),'Sales'[Account] = "Sales")
) 

% of Sales = divide(
[Total Amount],[Sales],0)

But, when i use this total to find the % of Sales it gives 0 for all the rows. That was the reason i was trying to do the ALLSELECTED. 

What am i missing 

AccountLocationTotal AmountLast Year Total% of Sales
MaterialsEU$95,325$17,3250
PackingAP$55,000 0
PackingUS$16,690$19,4200

 

 

 

Anonymous
Not applicable

Oh...I see, the % is a little bit tricky...you want to get the sales amount but keep the slicer filter flowing into the denominator as well? Try this:

Sales Total 2=

VAR CurYear = SELECTEDVALUE('Date'[Year],ALL('Date'[Year]) )

RETURN

CALCULATE( SUM('Sales'[Amount] ), FILTER(ALL(Sales), Sales[Year]=CurYear && Sales[Account]="Sales")

)

@Anonymous it is not clear what you are looking for, given the example what is your expected output, explain what is working and what is not working?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Anonymous 

Is this what you are looking for?

jdbuchanan71_0-1593310838199.png

I just changed the sales measure to ignore the selected account (on the row) and always return the amount for sales.

Sales = 
CALCULATE(
    [Total Amount],
    'Sales'[Account] = "Sales"
)

 

amitchandak
Super User
Super User

@Anonymous ,Try like

Sales Total =
CALCULATE( SUM('Sales'[Amount] ),All('Sales'))

 

% = divide( SUM('Sales'[Amount] ),[Sales Total])

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak  

 

The total is only for the [Account] = "Sales".  My slicer is Fiscal Year.  I have the % calculation working. My date table has relation set to the Period End Date. 

 

JournalFiscal YearFiscal PeriodAccountLocationPeriod end DateAmount
515020199MaterialsEU1/31/2019 0:00$1,800.00
5870201912MaterialsEU4/30/2019 0:00$15,525.00
1020220201MaterialsEU5/31/2019 0:00$48,000.00
34842606036MaterialsEU4/30/2020 0:00$47,325.00
11440202011PackingAP3/31/2020 0:00$55,000.00
5209201910PackingUS2/28/2019 0:00$1,720.00
5590201912PackingUS4/30/2019 0:00$17,700.00
1027520203PackingUS7/31/2019 0:00$16,690.00
90020202011SalesEU3/31/2020 0:00$428,868.00
80006201911SalesUS3/31/2019 0:00$185,000.00
90001202010SalesUS2/29/2020 0:00$188,111.00

 

 

@Anonymous , need expected output. Check if this can help

https://www.dropbox.com/s/k0opque79mpx0n6/sales_percent.pbix?dl=0

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak @parry2k @jdbuchanan71 

 

Apologies for not providing the expected result.

 

AccountLocationTotal AmountLast Year Total% of Sales
MaterialsEU$95,325$17,32515%
PackingAP$55,000 9%
PackingUS$16,690$19,4203%

% of sales = Total Amount / 616979 .  616979 is the total of "Sales" for 2020 FY. 

@Anonymous change sales total measure to this and everything will work

 

Sales Total = 
CALCULATE( SUM('Sales'[Amount] ),
    'Sales'[Account] = "Sales",
    ALLSELECTED ( Sales )
) 

 

parry2k_0-1593359704139.png

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.