Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I have a table in a variable:
Var Table1 =
Filter(
summarize(
Table1,
requestNum
startDate,
endDate,
employeeName,
createdOn,
),
employeeName = "John Smith" &&
| requestNum | startDate | endDate | employeeName | createdOn |
| req4001 | 6/22/2021 | 7/4/2021 | John Smith | 6/22/2021 |
| req4040 | 6/28/2021 | 7/1/2021 | John Smith | 6/28/2021 |
| vac6010 | 6/27/2021 | 7/3/2021 | John Smith | 5/24/2021 |
Then I have another variable that would get me the max requstNum i want:
Solved! Go to Solution.
Hi @wpf_
VAR Table1 = //... the code you already have and then:
VAR latestCreatedOn_ = MAXX(Table1, Table1[createdOn]) //Extract latest date
VAR auxT_ = FILTER(Table1, Table1[createdOn] = lastestCreatedOn_) //Get row with latest createdOn date
VAR maxReqNum_ = MAXX(auxT_, Table1[requestNum]) //Extract requestNum for that row
RETURN
maxReqNum_
Do note auxT_ should be a one-row table so using MINX at maxReqNum_ would also work. It's just a way to extract the value in the Table1[requestNum] columns
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Hi @wpf_
VAR Table1 = //... the code you already have and then:
VAR latestCreatedOn_ = MAXX(Table1, Table1[createdOn]) //Extract latest date
VAR auxT_ = FILTER(Table1, Table1[createdOn] = lastestCreatedOn_) //Get row with latest createdOn date
VAR maxReqNum_ = MAXX(auxT_, Table1[requestNum]) //Extract requestNum for that row
RETURN
maxReqNum_
Do note auxT_ should be a one-row table so using MINX at maxReqNum_ would also work. It's just a way to extract the value in the Table1[requestNum] columns
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
would this be ok?
maxx(filter(table1, tbale1[createdOn] = lastestCreatedOn_), table1[requestNum])
would it be faster to break it up like you did?
thanks
Sure. That is fine. I just split it in more steps above so that it was easier to follow.
As for the performance, I don't think there'd be a significant difference but it'd be a matter of checking with Dax Studio
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
@AlB Hi, can you help me with this? https://community.powerbi.com/t5/Desktop/Why-If-else-statemet-is-showing-both-results/m-p/1946253#M7...
It's a continuation of the formula you helped me with. THanks.
@wpf_ , Based on what I got,
You have to use measures like one for other columns
last requestNum=
VAR __id = MAX ('Table'[employeeName] )
VAR __date = CALCULATE ( Min('Table'[createdOn] ), ALLSELECTED ('Table' ), 'Table'[employeeName] = __id )
CALCULATE ( MAx ('Table'[requestNum] ), VALUES ('Table'[employeeName] ),'Table'[employeeName] = __id,'Table'[createdOn] = __date )
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |