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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.