Forum Discussion
Calculate highest value per period
- 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 !!
- 5 years ago
Anonymous
then i think you need to modify the model.
pls see the attachment below
- 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]) - 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]) - 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?
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_mayu5 years ago
Super User
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_mayu5 years ago
Super User
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?
- ryan_mayu5 years ago
Super User
you are welcome
- Anonymous5 years agoNot applicable
Hi ryan_mayu ,
Hope you are willing to give me one more advise.
If you look at the visual in the attachment: the info is coming from 3 different tables.
If I want to combine these 3 columns in 1 new table, is there a way to do so?
Thanks!
John
https://www.dropbox.com/s/iapjznegq73x5yl/highestvalue-v4.pbix?dl=0
- Anonymous5 years agoNot applicable
Hi ryan_mayu ,
So far so good!
However, see some double lines and also some lines do not have a price (BLANK or 0)
Is it possible to filter the double lines and BLANK or 0 - prices during the calculation of the table?
Hope this is my last question....can I sent you a pizza for your help?😊
John
- Anonymous5 years agoNot applicable
Good day ryan_mayu ,
You are right, my mistake.
Some parts are mentioned twice in the table, but with a different creditor.
Have added the column with the creditor in the table, works fine now.
The 0 and BLANK prices is also solved for now. It is simple, the price is not available.
Seems that for now, all is oke.
Many, many thanks for your help!
John
- ryan_mayu5 years ago
Super User
you are welcome
- Anonymous4 years agoNot applicable
Good day ryan_mayu ,
I am still working on this report, and found a (small?) issue in the outcome of the formulas.
In the test file which I added to this message, you see that the price of the selected part in month 2 (31,65) is not correct.
It should be 36,50.
Would you be so kind to look to the code you advised to see if there is a small issue there?
(I looked myself, but I am unable to solve the problem).
Thanks!
John
- ryan_mayu4 years ago
Super User
Anonymous
price.List returns a table, should not be a measure. i think you need to recreate a measure for that.