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
twanahc
Frequent Visitor

Search column1, If column2 is larger than 0 then return value from column 3 if match in column 4

Hi,

I know the title is a bit long and strange, i hope i can provide with a good explanation here.

I always find it easier to put things into context right at the start and then proceed with what i need your help with so i will do so.

 

Context

  • ColumnX is a column with what product item number that has been sold.
  • ColumnY is the quantity of that item sold/returned
  • ColumnZ is a invoice number and has a unique value for each specific invoice.
  • ColumnA links different types of invoice types together.
  • Column B is a column that states what type of invoice it is (Sales/Credit)

A table of this sort would look something like:

121.png

 

I would need your help to create a new calculated column that:

  1. Searches through every row.

  2. Checks if ColumnA on that searched row has a number greater than 0.
    Sales that have no credit note/return attached to it has 0 in ColumnA

  3. Returns the value of ColumnY from the corresponding matched invoice number of ColumnZ that is located in ColumnZ if columnX's number matches between the rows.

    I am a newbie at this but my attempt to grasp its logic as a concept is:
    If columnA is greater than 0 then search for ColumnA's number in ColumnZ to return the value of ColumnY to the row where columnA was greater than 0 if ColumnX's of both the rows match.

 

I greatly appreciate any help.

Thank you.

 

1 ACCEPTED SOLUTION

Hi @twanahc

In original table sheet1, create a calculated column

 

flag = CALCULATE(COUNT(Sheet1[A]),ALLEXCEPT(Sheet1,Sheet1[X]))

Then create a new table

 

Table1 = SUMMARIZE(FILTER(Sheet1,[flag]>1),[X],[Y],[Z],[B])

6.png

 

Create relationship with them

 

7.png

 

In original table sheet1, create a column

Column = IF([flag]>1,RELATED(Table1[Y]),0)

8.png

 

Best Regards

Maggie

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi

 

Good that you explained the requirement clearly. Could you please attach the expected result for the given sample data?

 

Thanks
Raj

Hey @Anonymous,

I hope i make sense on the attached picture below

 

CRPV.png

 

This is how i imagine it would look like.

The move thereafter is to create a measured column in the report to generate the net quantity delivered for each invoice.


Thanks,

Twana.

Hi @twanahc

In original table sheet1, create a calculated column

 

flag = CALCULATE(COUNT(Sheet1[A]),ALLEXCEPT(Sheet1,Sheet1[X]))

Then create a new table

 

Table1 = SUMMARIZE(FILTER(Sheet1,[flag]>1),[X],[Y],[Z],[B])

6.png

 

Create relationship with them

 

7.png

 

In original table sheet1, create a column

Column = IF([flag]>1,RELATED(Table1[Y]),0)

8.png

 

Best Regards

Maggie

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.