Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Solved! Go to Solution.
Hi @nursyeha001
Try adding a column with the expression below.
Valid Result =
VAR RowFirstName = 'Table'[First Name]
VAR RowLastName = 'Table'[Last Name]
VAR RowYear = 'Table'[Year]
VAR NoOfSubmissions =
CALCULATE (
COUNTROWS (
FILTER (
ALL ( 'Table' ),
'Table'[First Name] = RowFirstName
&& 'Table'[Last Name] = RowLastName
&& 'Table'[Year] = RowYear
)
)
)
VAR Result =
SWITCH (
TRUE(),
NoOfSubmissions > 1 && 'Table'[Assignments] = "Amended Submission", "Y",
NoOfSubmissions = 1, "Y",
"N"
)
RETURN Result
Note: this expression won't work if you have 2 or more people with the same name in the same year.
Best regards,
Martyn
Hi @nursyeha001 , @MartynRamsden ,
This also will not work if there are more than a max of two entries per year per person. For instance if you had two "Amended Submissions". So, as @MartynRamsden points out if two people have the same name this will not work, my suggestion is that you include in your table a unique identifier (an ID), and that you also have month, day, year to figure out which is the latest submission. Or as an alternative to a full date, you could have the submissions numbered, and we would take the maximum submission per unique ID.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
Hi @nursyeha001 ,
Your example does not seem to follow your written example. ATR? is not mentioned in the written portion. I also cannot tell if you have multiple tables and the relationships.
If you would share your pbix, or dummy up some values in Excel both for current and expected data. Please copy and paste them into your post, rather than doing a picture, we may be able to help you.
Please read this post to get your question answered more quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
Hi Nathaniel,
It's all in one table that I'm importing into Power BI and need to transform using DAX to create a column, Valid Record, that for each person, looks at the Assignments submitted for the Year and takes the latest version indicated with Y, any earlier versions will be indicated as a N.
Sample Data:
First Name | Last Name | Year | Assignments | Valid Record |
Peter | Parker | 2015 | Submission | N |
Peter | Parker | 2015 | Amended Submission | Y |
Tony | Stark | 2017 | Submission | Y |
Bruce | Wayne | 2018 | Submission | N |
Bruce | Wayne | 2018 | Amended Submission | Y |
Thanks!
Nur
Hi @nursyeha001
Try adding a column with the expression below.
Valid Result =
VAR RowFirstName = 'Table'[First Name]
VAR RowLastName = 'Table'[Last Name]
VAR RowYear = 'Table'[Year]
VAR NoOfSubmissions =
CALCULATE (
COUNTROWS (
FILTER (
ALL ( 'Table' ),
'Table'[First Name] = RowFirstName
&& 'Table'[Last Name] = RowLastName
&& 'Table'[Year] = RowYear
)
)
)
VAR Result =
SWITCH (
TRUE(),
NoOfSubmissions > 1 && 'Table'[Assignments] = "Amended Submission", "Y",
NoOfSubmissions = 1, "Y",
"N"
)
RETURN Result
Note: this expression won't work if you have 2 or more people with the same name in the same year.
Best regards,
Martyn
Hi @nursyeha001 , @MartynRamsden ,
This also will not work if there are more than a max of two entries per year per person. For instance if you had two "Amended Submissions". So, as @MartynRamsden points out if two people have the same name this will not work, my suggestion is that you include in your table a unique identifier (an ID), and that you also have month, day, year to figure out which is the latest submission. Or as an alternative to a full date, you could have the submissions numbered, and we would take the maximum submission per unique ID.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
User | Count |
---|---|
47 | |
26 | |
22 | |
17 | |
15 |
User | Count |
---|---|
55 | |
34 | |
18 | |
17 | |
15 |