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
privledged_test
New Member

DAX statement remove duplicate values

Is there a way to ignore duplicate values from source table using DAX? In below data "_DocTotalMisc" column is bringing same value for three order line but actual order form only has value in line 1 of the order. If there a DAX function where I can say if for particular Order#, line 1 has value <>0 then force line 2 and after to state "$0"?

 

privledged_test_1-1747664024786.png

 

1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @privledged_test ,

 

To show the value.OrderHed_DocTotalMisc only on the first line of each order and return 0 for all subsequent lines, you can write a DAX measure that identifies the first line number for each order and compares it with the current line in context. If it's the first line, return the value; otherwise, return 0. Here's the DAX:

DocTotalMisc_OneLineOnly =
VAR CurrentLine = SELECTEDVALUE('YourTable'[Line#])
VAR FirstLine =
    CALCULATE(
        MIN('YourTable'[Line#]),
        ALLEXCEPT('YourTable', 'YourTable'[Order#])
    )
RETURN
    IF(CurrentLine = FirstLine, MAX('YourTable'[value.OrderHed_DocTotalMisc]), 0)

Replace 'YourTable' with the actual table name. This will ensure the DocTotalMisc is only shown once per order, typically on the first line, and all other lines will display 0. This should be written as a measure to ensure proper behavior within visuals that filter by order and line.

 

Best regards,

View solution in original post

1 REPLY 1
DataNinja777
Super User
Super User

Hi @privledged_test ,

 

To show the value.OrderHed_DocTotalMisc only on the first line of each order and return 0 for all subsequent lines, you can write a DAX measure that identifies the first line number for each order and compares it with the current line in context. If it's the first line, return the value; otherwise, return 0. Here's the DAX:

DocTotalMisc_OneLineOnly =
VAR CurrentLine = SELECTEDVALUE('YourTable'[Line#])
VAR FirstLine =
    CALCULATE(
        MIN('YourTable'[Line#]),
        ALLEXCEPT('YourTable', 'YourTable'[Order#])
    )
RETURN
    IF(CurrentLine = FirstLine, MAX('YourTable'[value.OrderHed_DocTotalMisc]), 0)

Replace 'YourTable' with the actual table name. This will ensure the DocTotalMisc is only shown once per order, typically on the first line, and all other lines will display 0. This should be written as a measure to ensure proper behavior within visuals that filter by order and line.

 

Best regards,

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.