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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Vamshi_PBI
Frequent Visitor

Help with DAX ALLSelected

Hi Team,

 

I need some help with writing dax formula. PFB details.

 

My data model is having 2 tables and the data modelling as below . My datasource is a combination of live and direct query.

 

DimProduct: 

ProductProduct Key
Apple1
Banana2
Orange3
Mango4

 

FactSales: 

 

ProductForeignKeyAmount
110
110
220
330
440
440

 

Vamshi_PBI_0-1707477556742.png

 

So i would like to take product key, product foreign key into table visual and dispaly the total sum of amount (150) againist each row by using ALLSelected function as below.

All Amount = CALCULATE(SUM(FactSales[Amount]),ALLSELECTED(FactSales))
 
But as soon as I include ALL or ALLSelected a Cross Join is happening between productkey and productforeign key as below.
 

Vamshi_PBI_1-1707478091624.png

 

So, I would like to show total sum for all rows and Product Key filter should work, for example if i choose only Product 1 & 2, the total sum should be displaying for all rows is 30 (10+20).

 

Please help with this, any help is very much appreciated.

 

Thanks.

 

6 REPLIES 6
Anonymous
Not applicable

Hi @Vamshi_PBI

 

Your problem may be related to using the ALLSELECTED function in DirectQuery mode.

 

One possible solution is to use the KEEPFILTERS function instead of ALLSELECTED. The KEEPFILTERS function preserves the existing filters in the filter context and applies them to the specified column or table. For example, you can create a new measure like this:

 

All Amount = 
    CALCULATE(
        SUM(FactSales[Amount]),
        KEEPFILTERS(FactSales)
    )

 

 

If you still have problems, it's best to provide the pbix file with your expected results and be careful to remove sensitive data.

 

Regards,

Nono Chen

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

Daniel29195
Super User
Super User

@Vamshi_PBI 

All Amount = CALCULATE(SUM(FactSales[Amount]),ALLSELECTED(dimproduct[productname]))

 

 

 

 

If this answers your question  ,  mark it as the solution so can you can help  other people in the community find it easily .

Hi @Daniel29195 ,

 

With this approach , cross join wont happen, but total sum (for selected products or all products) is not reflected for all rows. 

 

Vamshi_PBI_0-1707653425515.png

 

Thanks.

@Vamshi_PBI 

if you are intending of using all the product columns into the visual : 

All Amount = CALCULATE(SUM(FactSales[Amount]),ALLSELECTED(dimproduct))

 

 

Hi @Daniel29195 , Sorry for the late response.

 

This still resulting in cross join and total value is also not diplayed againist each row.

 

Vamshi_PBI_0-1707999791325.png

 

Thanks.

@Vamshi_PBI 

please if possible, share the file so i can take a closer look at the issue . ( via google drive or dropbox)

 

best regards

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors