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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Libin7963
Helper II
Helper II

Unique values in calculated column

In direct query how can I achieve this calculated column using dax please

Product NumberColour IDCalculated Column
12311
12321
12331
12341
12351
12361
256AA
256CA
256dA
256eA
256fA
256gA
256hA
1 ACCEPTED SOLUTION

Hey! Sorry to hear that, maybe try this Dax measure: 

Calculated_Column_Measure =
VAR FirstValue =
CALCULATE(
MIN('Table'[Colour ID]),
ALLEXCEPT('Table', 'Table'[Product Number])
)
RETURN
FirstValue

 

----- CALCULATE(MIN('Table'[Colour ID])...) finds the minimum Colour ID per Product Number.
 and ALLEXCEPT('Table', 'Table'[Product Number]) ensures that the calculation is performed only within each Product Number group.

 

Tell me if this works! 😁😁

View solution in original post

3 REPLIES 3
freginier
Super User
Super User

Hey there!

 

If I understand correctly, you want to create a calculated column in DirectQuery mode that assigns the same value to all rows with the same Product Number group.

 

I think you could use this DAX formula:

Calculated_Column =
VAR FirstValue =
MINX(
FILTER(
'Table',
'Table'[Product Number] = EARLIER('Table'[Product Number])
),
'Table'[Colour ID]
)
RETURN
FirstValue

 

It will identify the First Colour ID within each Product Number group. Use MINX to find the first unique value in Colour ID for each Product Number. And assign that value to all rows where Product Number is the same.

 

Hope this works!

😁😁

Function 'MINX' is not allowed as part of calculated column DAX expressions on DirectQuery models. I am getting this message

Hey! Sorry to hear that, maybe try this Dax measure: 

Calculated_Column_Measure =
VAR FirstValue =
CALCULATE(
MIN('Table'[Colour ID]),
ALLEXCEPT('Table', 'Table'[Product Number])
)
RETURN
FirstValue

 

----- CALCULATE(MIN('Table'[Colour ID])...) finds the minimum Colour ID per Product Number.
 and ALLEXCEPT('Table', 'Table'[Product Number]) ensures that the calculation is performed only within each Product Number group.

 

Tell me if this works! 😁😁

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.