Forum Discussion

ngct1112's avatar
ngct1112
Post Patron
4 years ago
Solved

DAX - Filter before Summarize

Hi All,

I would like to seek some helps for the DAX to summarize the "QTY" by "ID". However, I would like to Filter the "Status" to Ordered only before summarize.

IDQTYStatus
17Ordered
14Cancelled
22Ordered
28Cancelled
34Ordered

 

Desired outcome:

IDQTY
17
22
34

 

I am tyring with the DAX but still fail. Appreciated if you have any idea. Thanks

 

_Table = 
ADDCOLUMNS(
SUMMARIZE(FILTER('Table','Table'[Status]="Ordered"),'Table'[ID]), 
"SUM", CALCULATE(SUM('Table'[QTY])))

 

  • Try

    _Table = 
    
    SUMMARIZE(FILTER('Table','Table'[Status]="Ordered"),'Table'[ID], 
    "SUM", CALCULATE(SUM('Table'[QTY])))

3 Replies

  • Hi,
    Please try the below for creating a new table.

     

    _Table =
    VAR filteredtable =
    FILTER ( 'Table', 'Table'[Status] = "Ordered" )
    VAR newtable =
    SUMMARIZE ( filteredtable, 'Table'[ID], 'Table'[QTY] )
    RETURN
    newtable

     

  • FarhanAhmed's avatar
    FarhanAhmed
    Community Champion

    Try

    _Table = 
    
    SUMMARIZE(FILTER('Table','Table'[Status]="Ordered"),'Table'[ID], 
    "SUM", CALCULATE(SUM('Table'[QTY])))
    • ngct1112's avatar
      ngct1112
      Post Patron

      FarhanAhmed  you solution works very fine. May I know how it is possible that your solution can still work without ADDCOLUMN?
      Great thanks anyways