Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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

3 Replies

  • Anonymous's avatar
    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

  • 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 )
    )

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

    I have updated the attached .pbix with both.