Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Need help summing values based on different columns

Hello Community!   I am hoping someone can help on this today (as it's needed for Monday).     I've provided an example data set (below), and my current attempt at what I am trying to do.    The re...
  • v-yueyunzh-msft's avatar
    v-yueyunzh-msft
    3 years ago

    Hi , Anonymous 

    According to your description, you want to use the Year_month as column and get the sum of the [Net Price] based on two columns.

    Here are the steps you can refer to :
    (1)My test data is the same  as your provided.

    (2) I create a calendar Table like your said.

    (3)We can create a measure like this:

    Measure = 
    var _date  = MAX('Dim_Date'[Date])
    var _t  = FILTER( ALL('Table') , OR( YEAR( 'Table'[Due Date]) = YEAR( _date) && MONTH( 'Table'[Due Date]) = MONTH(_date ) , YEAR( 'Table'[Commit Date]) = YEAR( _date) && MONTH( 'Table'[Commit Date]) = MONTH(_date )   ))
    
    return
    IF(_date<> BLANK() , SUMX(_t , [Net Price]) )
    
    

    Then we can put it on the visual and we can get the result as follows:

     

     

     

     

    If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly