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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Mniknejad
Frequent Visitor

add a new column and show an ID has same positive and negative data

I would like to know how cn I add a column im my report to show an ID have same positive and negative data 

 

I have a line table and it includes all salesorder data and  a salesorder can include sales and return data in a same time sale amount is positive and returns is negative I need to add a column in my report to show if  salesorder include return  and sales show "yes" otherwise "NO"

 

TransactionIdProductIdInfoCodeNetAmountEXCHANGE
R11-5081770NULL-650YES
R11-50263879NULL1050YES
R11-5054599NULL-925YES
R11-50237164NULL995YES
R08-525198879NULL-275NO
R08-52523471NULL-546NO
R02-12982235905NULL935NO
R02-1298243749NULL995NO
1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

If I understand correctly, this DAX column expression should work.  Just replace Exchanges with your actual table name.

 

Has Pos and Neg Values =
VAR thisID = Exchange[TransactionId]
VAR haspos =
    COUNTROWS (
        FILTER ( Exchange, Exchange[NetAmount] > 0 && Exchange[TransactionId] = thisID )
    ) > 0
VAR hasneg =
    COUNTROWS (
        FILTER ( Exchange, Exchange[NetAmount] < 0 && Exchange[TransactionId] = thisID )
    ) > 0
RETURN
    IF ( haspos && hasneg, "Yes", "No" )

 

 

Pat

 

mahoneypat_0-1628122468533.png





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

1 REPLY 1
mahoneypat
Microsoft Employee
Microsoft Employee

If I understand correctly, this DAX column expression should work.  Just replace Exchanges with your actual table name.

 

Has Pos and Neg Values =
VAR thisID = Exchange[TransactionId]
VAR haspos =
    COUNTROWS (
        FILTER ( Exchange, Exchange[NetAmount] > 0 && Exchange[TransactionId] = thisID )
    ) > 0
VAR hasneg =
    COUNTROWS (
        FILTER ( Exchange, Exchange[NetAmount] < 0 && Exchange[TransactionId] = thisID )
    ) > 0
RETURN
    IF ( haspos && hasneg, "Yes", "No" )

 

 

Pat

 

mahoneypat_0-1628122468533.png





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors