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

Lookup Value in two columns and return rows

Hi Everyone. 

 

I need your help on this. 

I have two table ( Item table and Sales Table). I have a slicer for item number("No") from the item table and a relationship between the two tables.  The table are shown below. 

 

Item Table 

NoGen NoDesc 1Desc 2
1-DogBlack
21Dog 2White
3-Dog 3Gold
41Dog 4White and Black
5-Dog 5Spotted 
61Dog 6Brown
    

 

Sales Table 

NoGen NoDesc 1Desc 2Qty
1-DogBlack4
21Dog 2White5
3-Dog 3Gold8
41Dog 4White and Black6
5-Dog 5Spotted 2
61Dog 6Brown1

 

 

If i select "No" =1 from the slicer, i want to check on the sales table where the "No" =1 and also where the "Gen No" = 1 and i want to get the result table below

 

NoGen NoDesc 1Desc 2Qty
1-DogBlack4
21Dog 2White5
41Dog 4White and Black6
61Dog 6Brown1

 

I hope i was descriptive enough.

 

 

5 REPLIES 5
amitchandak
Super User
Super User

Try if this can solve

QTY_1 = calculate(sum(qty), filter(all(sales),sales[No]=allselected(sales[No]) || sales[Gen No]=allselected(sales[No])))

 

Use QTY in your table.

 

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 Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

Many thanks @amitchandak . 

However, the expression did not work. It showed "Cant display the visual" when i tried to use it. 

 

 

There is a link to see the error. what is the error it is giving

@amitchandak 

MdxScript(Model) (33, 182) Calculation error in measure 'Sales'[QTY_1]: A table of multiple values was supplied where a single value was expected.

Try if in can work. else provide sample pbix.

 

QTY_1 = calculate(sum(qty), filter(all(sales),sales[No] in allselected(sales[No]) || sales[Gen No] in allselected(sales[No])))

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.