Forum Discussion
Total newbie need some help.
Hi,
I am a total beginner.
I am starting to tinker a little bit with power BI in order to create some KPI for my job, but i am struggling a little bit.
Here is my current issue.
I have a table in which i have a reccord of all the quotation issued by my company. The simplified structure of this table is as follows:
date idProject idVersion netPrice
01/02/2018 0001 10 1111
18/06/2018 0001 20 2222
21/06/2019 0001 30 3333
30/08/2019 0002 10 4444
30/09/2019 0002 20 5555
I want to create a report that display , for a given period, the list of the sent quotation keeping only the latest version of each project in the given period.
For exemple, if i filter on 2018, i expect to see:
date idProject idVersion netPrice
18/06/2018 0001 20 2222
if i filter on 2019, i expect to see:
date idProject idVersion netPrice
21/06/2019 0001 30 3333
30/09/2019 0002 20 5555
I have imported my table in power BI, and i started creating a report.
I have a filter that allow to select the period. It work as expected.
I have created a "table display" with the following values: date, idProject and a quick measure making the following calculation:
lastIdVersionInThePeriod =
MAXX(
KEEPFILTERS(VALUES('Table'[idProject]));
CALCULATE(MAX('Table'[idVersion ]))
)
it works quite well, and i get this (if i filter on 2019):
date idProject idVersion
21/06/2019 0001 30
30/09/2019 0002 20
If i add the netPrice value in the table, it does not work anymore, and it will display all the version in the period (not only the last one)
I suspect, i am not doing it properly,
Can someone point me in the right direction ?
sorg try this measure
Measure = VAR __id = MAX ( 'Table'[id] ) VAR __date = CALCULATE ( MAX( 'Table'[date] ), ALLSELECTED ( 'Table' ), 'Table'[id] = __id ) RETURN CALCULATE ( MAX ( 'Table'[netprice] ), VALUES ( 'Table'[id] ), 'Table'[id] = __id, 'Table'[date] = __date )and you will get this output.
Would appreciate Kudos ๐ if my solution helped.
4 Replies
- amitchandak
Super User
Add a desc rank based on the project and date. And the filter on rank =1
Refer
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601- parry2k
Super User
sorg try this measure
Measure = VAR __id = MAX ( 'Table'[id] ) VAR __date = CALCULATE ( MAX( 'Table'[date] ), ALLSELECTED ( 'Table' ), 'Table'[id] = __id ) RETURN CALCULATE ( MAX ( 'Table'[netprice] ), VALUES ( 'Table'[id] ), 'Table'[id] = __id, 'Table'[date] = __date )and you will get this output.
Would appreciate Kudos ๐ if my solution helped.
- sorgNew Member
I tried, but could not use your solution. At some point i have an error message because idVersion is not unique and i don't aggregate the values.