The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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:
Product | Product Key |
Apple | 1 |
Banana | 2 |
Orange | 3 |
Mango | 4 |
FactSales:
ProductForeignKey | Amount |
1 | 10 |
1 | 10 |
2 | 20 |
3 | 30 |
4 | 40 |
4 | 40 |
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.
Please help with this, any help is very much appreciated.
Thanks.
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.
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.
Thanks.
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.
Thanks.
please if possible, share the file so i can take a closer look at the issue . ( via google drive or dropbox)
best regards