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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Dax code to summarise data based on two column inputs to determine the value

I have been looking every where for some assistance in summarising data with DAX code to get the following output. I have option 1 and 2 but preference is option 2.

Original Data
OrderSufAmount
5000200
5001150
5001200
5002300
5010400
5020300
5020200
5021400
5021300
5022100
5033100

 

Output

Option 1
OrderAmountSufAmount
5008500200
500 1350
500 2300
5014000400
50214000500
502 1700
502 2100
502 3100

 

Option 2 - Prefered
OrderTotalSufAmountSufAmountSufAmountSufAmount
500850020013502300  
5014000400      
50214000500170021003100
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

You can create the calculated table like this.

Table 2 = 
SUMMARIZE (
    'Table',
    'Table'[Order],
    "Total", SUM ( 'Table'[Amount] ),
    "Suf 0", CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Suf] = 0 ),
    "Suf > 0", CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Suf] > 0 )
)

jdbuchanan71_0-1636514106837.png

Or did you mean in a table visual which would be like this.

jdbuchanan71_1-1636514249979.png

I have updated the attached .pbix with both.

 

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

You can create the calculated table like this.

Table 2 = 
SUMMARIZE (
    'Table',
    'Table'[Order],
    "Total", SUM ( 'Table'[Amount] ),
    "Suf 0", CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Suf] = 0 ),
    "Suf > 0", CALCULATE ( SUM ( 'Table'[Amount] ), 'Table'[Suf] > 0 )
)

jdbuchanan71_0-1636514106837.png

Or did you mean in a table visual which would be like this.

jdbuchanan71_1-1636514249979.png

I have updated the attached .pbix with both.

 

Anonymous
Not applicable

Thanks for looking into it. The problem with the data set is that Suf could go to 999. At the end, I am more interested in total of Suf 0 and then the total of all Suf >0.

 

Also I need the data in a new table with Total Order, Total Suf 0 and Toal for Suf>0

jdbuchanan71
Super User
Super User

@Anonymous 

There are a couple different ways you could organize it to get that view.

jdbuchanan71_0-1636510722517.png

The second one is the simplest.  I have attached my sample file for you to look at.

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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