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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Lazurens
Frequent Visitor

How to Sum Quantities and Adjust for Repeated Values in DAX

I'm working with a dataset in DAX where I encounter repeating values labeled as "nominal" and "opening" for each combination of date and wonumber. My objective is to sum the quantities for each date and wonumber. However, I need to adjust this sum by considering only one occurrence of either "nominal" or "opening" in each date and wonumber combination.

 

Could someone assist me with the DAX formula needed to sum the quantities per date and wonumber, and then divide this sum by the count of unique occurrences of "nominal" and "opening" for each date and wonumber combination?

 

Example illustrating the shape of the data and the calculation : 

Lazurens_0-1700564291914.png

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Lazurens ,

I created a sample pbix file(see the attachment), please check if that is what you want.

Result = 
VAR _tab =
    SUMMARIZE (
        'Table',
        'Table'[Date production],
        'Table'[Wnum],
        'Table'[Nominal],
        'Table'[Opening],
        "@sumofqty", SUM ( 'Table'[Quantity] )
    )
VAR _qty =
    SUMX ( _tab, [@sumofqty] )
VAR _nominal =
    MAXX ( _tab, [Nominal] )
VAR _opening =
    MAXX ( _tab, [Opening] )
RETURN 
    _qty / DIVIDE ( _opening, 3600 ) * _nominal

vyiruanmsft_0-1700732971281.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Lazurens ,

I created a sample pbix file(see the attachment), please check if that is what you want.

Result = 
VAR _tab =
    SUMMARIZE (
        'Table',
        'Table'[Date production],
        'Table'[Wnum],
        'Table'[Nominal],
        'Table'[Opening],
        "@sumofqty", SUM ( 'Table'[Quantity] )
    )
VAR _qty =
    SUMX ( _tab, [@sumofqty] )
VAR _nominal =
    MAXX ( _tab, [Nominal] )
VAR _opening =
    MAXX ( _tab, [Opening] )
RETURN 
    _qty / DIVIDE ( _opening, 3600 ) * _nominal

vyiruanmsft_0-1700732971281.png

Best Regards

lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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