Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Islam
Helper V
Helper V

create sorted table and keep duplicates

hello everyone 

i have a fact table have duplicated employees ID and wanna sort it with keeping duplicates and then get the last corresponding value from another column in the same table like following

EmpIDValue1value2
1100110
2101111
3102112
1103113
3104114
2105115
4106116
5107117
4108118
5109119

 

and i wanna result table as following

 

1103113
2105115
3104114
4108118
5109119

 

and if there is only one value for any employee then it returns the corresponding values

1 ACCEPTED SOLUTION
Islam
Helper V
Helper V

thanks to all who tried to help me out with this but actually it worked for me using the following measures

Hierarchy Title =
VAR CurrentHierarchy = SELECTEDVALUE(fTransactions[EmpID])
RETURN
MINX(FILTER(ALLSELECTED(fTransactions),fTransactions[EmpID]=CurrentHierarchy),RELATED(dHierarchy[Hierarchy title]))
 
 
Main Degree Title =
VAR CurrentMainDegree = SELECTEDVALUE(fTransactions[EmpID])
RETURN
MINX(FILTER(ALLSELECTED(fTransactions),fTransactions[EmpID]=CurrentMainDegree),RELATED(dMainDegree[Degree]))
 
 
Sub Degree Title =
VAR CurrentSubDegree = SELECTEDVALUE(fTransactions[EmpID])
RETURN
MINX(FILTER(ALLSELECTED(fTransactions),fTransactions[EmpID]=CurrentSubDegree),RELATED(dSubDegrees[Sub Degree]))

View solution in original post

16 REPLIES 16
Islam
Helper V
Helper V

thanks to all who tried to help me out with this but actually it worked for me using the following measures

Hierarchy Title =
VAR CurrentHierarchy = SELECTEDVALUE(fTransactions[EmpID])
RETURN
MINX(FILTER(ALLSELECTED(fTransactions),fTransactions[EmpID]=CurrentHierarchy),RELATED(dHierarchy[Hierarchy title]))
 
 
Main Degree Title =
VAR CurrentMainDegree = SELECTEDVALUE(fTransactions[EmpID])
RETURN
MINX(FILTER(ALLSELECTED(fTransactions),fTransactions[EmpID]=CurrentMainDegree),RELATED(dMainDegree[Degree]))
 
 
Sub Degree Title =
VAR CurrentSubDegree = SELECTEDVALUE(fTransactions[EmpID])
RETURN
MINX(FILTER(ALLSELECTED(fTransactions),fTransactions[EmpID]=CurrentSubDegree),RELATED(dSubDegrees[Sub Degree]))
Ashish_Mathur
Super User
Super User

Hi,

Drag EmpID to the Table visual and write these 2 measures

Max of value 1 = max(Data[value1])

Max of value 2 = max(Data[value2])


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

ok sir I'll try this out

Hi @Islam ,

 

Is your issue solved now?If so,could you pls mark the reply as answered to close it?

 

 

Best Regards,
Kelly

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

ryan_mayu
Super User
Super User

@Islam 

1. create an index column in pq

1.PNG

2. create two measures

_value1 = 
VAR _max=maxx(FILTER('Table','Table'[EmpID]=MAX('Table'[EmpID])),'Table'[Index])
return maxx(FILTER('Table','Table'[Index]=_max),'Table'[Value1])


_value2 = 
VAR _max=maxx(FILTER('Table','Table'[EmpID]=MAX('Table'[EmpID])),'Table'[Index])
return maxx(FILTER('Table','Table'[Index]=_max),'Table'[value2])

2.PNG

please see the attachment below





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

Proud to be a Super User!




thx for help sir but i already have an index column embeded in my fact table so can't i add an index column in the resulted summerized table using dax ?

@Islam 

if you already have an index column then skip the first step and create measure directly





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

Proud to be a Super User!




ah ok that's a good idea I'll try this and let you know the results

Hi @Islam ,

 

Create a measure as below:

_index = IF(MAX('Table'[Index])=CALCULATE(MAX('Table'[Index]),FILTER(ALL('Table'),'Table'[EmpID]=MAX('Table'[EmpID]))),1,BLANK())

Then put the measure in the filter pane,choose "is not blank":

v-kelly-msft_0-1617175530621.png

 

And you will see:

v-kelly-msft_1-1617175546826.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

i'm getting crazy brother i tested your measure and it gives a perfect answers for your model but for mine it gives me both two SubDegreeID like this image

 

1.png

 

Hi @Islam ,

 

Dont worry,you should use "ALL"  instead of "VALUES"."VALUES" is not suitable here.

 

Best Regards,
Kelly

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

 

 

thanks for your help sir but it gave me an empty values like following picture

 

1.png

 

HarishKM
Memorable Member
Memorable Member

@Islam Hey , 

Picture 1 . Fact table .

HarishKM_1-1617033261161.png

 


You can use below formula,

Test Sample = SUMMARIZE(
'Test table',
'Test table'[EmpID],
"value1", MAX('Test table'[Value1]),
"value2" ,MAX('Test table'[value2]
))
Expected Result using below dax.
HarishKM_0-1617033208868.png

 



if i am able resolve your problem then  Give me kudos and mark it as solution .

thanks for help sir but i'm afraid it doesn't completely work for me because when i swap the values for EmpID number 1 for example it gave me 113 and 103 in values although it should give me 110 and 100

selimovd
Super User
Super User

Hey @Islam ,

 

if it is just 2 columns you can achieve that with the LOOKUPVALUE function in DAX.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Unfortunately it's not exactly what i need sir what i need is generating a table with last values for unique employees

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors