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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
summer18
Helper III
Helper III

Display the sum of a category

I need help on the formula on how can I display the correct values per category. 

 

Scenario:  I have an existing table chart in PowerBI and the picture below displays some of the columns (except Product Volume) in the table chart.  I want to create "Product Volume" measure = sum of "Product SKU Volume" per "Product".  It will display the Product Volume data on the min Product SKU only, the others will be blank/null so it will not display as repetitive values.  The desired output is shown on the pic below.

 

sample101.jpg

 

Hoping someone can help me on this because I've been working on this specific formula for a week already and could not make it to work.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1707712067887.png

 

Jihwan_Kim_1-1707712378576.png

 

 

 

Product SKU volume measure: = 
SUM( fact_volume[Product SKU Volumn] )

 

INDEX function (DAX) - DAX | Microsoft Learn

 

expected result measure: = 
VAR _result =
    CALCULATE (
        [Product SKU volume measure:],
        ALLEXCEPT ( dim_product, dim_product[Product] )
    )
VAR _condition =
    MAX ( dim_product[Product SKU] )
        = MAXX (
            INDEX (
                1,
                ALL ( dim_product ),
                ORDERBY ( dim_product[Product SKU], ASC ),
                ,
                PARTITIONBY ( dim_product[Product] )
            ),
            dim_product[Product SKU]
        )
RETURN
    _result * DIVIDE ( _condition, _condition )

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1707712067887.png

 

Jihwan_Kim_1-1707712378576.png

 

 

 

Product SKU volume measure: = 
SUM( fact_volume[Product SKU Volumn] )

 

INDEX function (DAX) - DAX | Microsoft Learn

 

expected result measure: = 
VAR _result =
    CALCULATE (
        [Product SKU volume measure:],
        ALLEXCEPT ( dim_product, dim_product[Product] )
    )
VAR _condition =
    MAX ( dim_product[Product SKU] )
        = MAXX (
            INDEX (
                1,
                ALL ( dim_product ),
                ORDERBY ( dim_product[Product SKU], ASC ),
                ,
                PARTITIONBY ( dim_product[Product] )
            ),
            dim_product[Product SKU]
        )
RETURN
    _result * DIVIDE ( _condition, _condition )

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

It works!  Thank you very much @Jihwan_Kim  for the solution and the pbix  😊

danextian
Super User
Super User

Hi @summer18 ,

 

Can you please post your data as a workable table, not an image? You may post a link to an Excel file online.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Please try either:

Calc Column =
VAR __MIN_SKU =
    CALCULATE ( MIN ( data[SKU] ), ALLEXCEPT ( data, data[Product] ) )
VAR __TOTAL_BY_PRODUCT =
    CALCULATE ( SUM ( data[Volume] ), ALLEXCEPT ( data, data[Product] ) )
RETURNjUST
    IF ( data[SKU] = __MIN_SKU, __TOTAL_BY_PRODUCT )
Measure =
VAR __MIN_SKU =
    CALCULATE ( MIN ( data[SKU] ), ALLEXCEPT ( data, data[Product] ) )
VAR __TOTAL_BY_PRODUCT =
    CALCULATE ( SUM ( data[Volume] ), ALLEXCEPT ( data, data[Product] ) )
RETURN
    IF ( SELECTEDVALUE ( data[SKU] ) = __MIN_SKU, __TOTAL_BY_PRODUCT 









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.