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
sustar2020
Regular Visitor

DAX help: calculate Sum by each category: not getting the right results

I am trying to calculate the total recipe cost price for each recipe. I used the below DAX formula as shown in the image and also listed below but I am not getting the correct result. I am trying to acheive this in a Power Bi Matrix visual. Please help.

Recipe Total Cost Price = Calculate(SUM('All Recipes'[Ingredient_Cost_Price]), ALLEXCEPT('All Recipes','All Recipes'[Recipe Name]))

 

PowerBi.PNG

1 ACCEPTED SOLUTION

HI @sustar2020,

You can try to use the following measure formula if that is suitable for your requirement:

Recipe Total Cost Price =
CALCULATE (
    SUM ( 'All Recipes'[Ingredient_Cost_Price] ),
    ALLSELECTED ( 'All Recipes' ),
    VALUES ( 'All Recipes'[Recipe Name] )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
sustar2020
Regular Visitor

Hi, sorry, it didn't work. It's giving an empty column.

HI @sustar2020,

You can try to use the following measure formula if that is suitable for your requirement:

Recipe Total Cost Price =
CALCULATE (
    SUM ( 'All Recipes'[Ingredient_Cost_Price] ),
    ALLSELECTED ( 'All Recipes' ),
    VALUES ( 'All Recipes'[Recipe Name] )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@sustar2020 , if Ingredient_Cost_Price is a column this seems fine to me

 

But you can try

 

Recipe Total Cost Price = Calculate(SUM('All Recipes'[Ingredient_Cost_Price]), filter(allselected('All Recipes') ,'All Recipes'[Recipe Name] = max('All Recipes'[Recipe Name]) ))

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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.