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
MdJ83
Helper II
Helper II

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.

 

MdJ83
Helper II
Helper II

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

@MdJ83 

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
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.