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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
setis
Post Partisan
Post Partisan

Calculated column and FIRSTNONBLANK

Dear all,

 

I have a calulated column in a table to bring a value from another table that have not relationship in the data model with each other. 

 

I am in my Sales Invoice Line and the calculated column is:

Amount w VAT2 = 
CALCULATE(
    FIRSTNONBLANK('Job Ledger Entry'[Price LCY (inc VAT)];1);
    FILTER(Job Ledger Entry';
    'Job Ledger Entry'[Document No_] = 'Sales Invoice Line'[Document No_] &&
    'Sales Invoice Line'[Identifier] = 'Job Ledger Entry'[Identifier]))

 

My problem is that I'm facing a case that has 2 lines in Job Ledger Entry. One with the amount in + and the other in -. 

Both lines have the same Document No_ and Identifier. 

 

I would line to bring both values. Is it possible?

 

Thank you in advance

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @setis,

You can try to use CONCATENATEX function to combine all matched records:

Amount w VAT2 =
CALCULATE (
    CONCATENATEX (
        VALUES ( 'Job Ledger Entry'[Price LCY (inc VAT)] );
        [Price LCY (inc VAT)];
        ";"
    );
    FILTER (
        'Job Ledger Entry';
        [Price LCY (inc VAT)] <> BLANK ()
            && [Document No_] = EARLIER ( 'Sales Invoice Line'[Document No_] )
            && [Identifier] = EARLIER ( 'Sales Invoice Line'[Identifier] )
    )
)

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @setis,

You can try to use CONCATENATEX function to combine all matched records:

Amount w VAT2 =
CALCULATE (
    CONCATENATEX (
        VALUES ( 'Job Ledger Entry'[Price LCY (inc VAT)] );
        [Price LCY (inc VAT)];
        ";"
    );
    FILTER (
        'Job Ledger Entry';
        [Price LCY (inc VAT)] <> BLANK ()
            && [Document No_] = EARLIER ( 'Sales Invoice Line'[Document No_] )
            && [Identifier] = EARLIER ( 'Sales Invoice Line'[Identifier] )
    )
)

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

You can use sumx. It will sum. As new column

 

 new Column = sumx(FILTER('Job Ledger Entry';
    'Job Ledger Entry'[Document No_] = 'Sales Invoice Line'[Document No_] &&
    'Sales Invoice Line'[Identifier] = 'Job Ledger Entry'[Identifier]),'Job Ledger Entry'[Price LCY (inc VAT)])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

 

ImkeF
Super User
Super User

Hi @setis  

what would you like to do with those 2 values? Add them up?

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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