Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Calculate highest value per period

Hi all,   Hope someone can help me with the following.   Below is a simple start-table. I am looking for a way to calculate the highest PART.PRICE per YEAR-MONTH for that particular PARTNUMBER_S...
  • VahidDM's avatar
    5 years ago

    Hi Anonymous 

     

    Add all columns to the table and change the aggragation of "part.price" column to Max.

     

    If you need another table, use the below code to create a new table:

    Table 2 =
    SUMMARIZE (
        'Table',
        'Table'[invoice_date_year],
        'Table'[invoice_date_month],
        'Table'[partnumber_sup],
        "MaxPart Price", MAX ( 'Table'[part.price] )
    )

     

     

    Did I answer your question? Mark my post as a solution!

    Appreciate your Kudos  !!

     

  • ryan_mayu's avatar
    ryan_mayu
    5 years ago

    Anonymous 

    is this what you want?

    Column = 
    VAR _DATE=MAXX(FILTER('Table',Purchase[partnumber_sup]='Table'[partnumber_sup]&&'Table'[date]<='Purchase'[order_dat]),'Table'[date])
    RETURN 
    maxx(FILTER('Table',Purchase[partnumber_sup]='Table'[partnumber_sup]&&'Table'[date]=_DATE),'Table'[part.price])

  • ryan_mayu's avatar
    ryan_mayu
    5 years ago

    Anonymous 

    pls try this

    Table = 
    VAR _time=ADDCOLUMNS(SUMMARIZE('date','date'[year],'date'[month]),"_date",date('date'[year],'date'[month],1),"d_y_m",CONCATENATE('date'[year] & " " , 'date'[month])
    )
    VAR tbl= ADDCOLUMNS(ADDCOLUMNS(ADDCOLUMNS(CROSSJOIN(dim,_time),"min",CALCULATE(min('listprijzen_per_maand'[invoice_date]),FILTER('listprijzen_per_maand',listprijzen_per_maand[partnumber_sup]=EARLIER('dim'[partnumber_sup])))),"scope",if([min]>[_date],"No")),"_price",
    VAR p=maxx(FILTER('listprijzen_per_maand',dim[partnumber_sup]=listprijzen_per_maand[partnumber_sup]&&[_date]='listprijzen_per_maand'[invoice_date]),'listprijzen_per_maand'[part.price])
    VAR _last=maxx(FILTER('listprijzen_per_maand',dim[partnumber_sup]=listprijzen_per_maand[partnumber_sup]&&[_date]>listprijzen_per_maand[invoice_date]),listprijzen_per_maand[invoice_date])
    var P2=maxx(FILTER('listprijzen_per_maand',dim[partnumber_sup]=listprijzen_per_maand[partnumber_sup]&&_last=listprijzen_per_maand[invoice_date]),'listprijzen_per_maand'[part.price])
    return if(ISBLANK(p),p2,p))
    return SELECTCOLUMNS(FILTER(tbl,[scope]<>"No"),"Date_year_month",[d_y_m],"partnumber",dim[partnumber_sup],"Price",[_price])

  • ryan_mayu's avatar
    ryan_mayu
    5 years ago

    Anonymous 

    i think in the sample file. we also have double lines in the price table.

    i also tried to add a blank price in your sample file. It looks like the result does not changed.

    pls see the attachment below

    could you pls send me the your pbix file?