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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Laura1996
Frequent Visitor

Show all entries of the same number where there exists an "-" and a "+"

 

Laura1996_1-1673597134217.png

 

I have a table with thousands of entries with material numbers (Material) - those Material has certain movement, which is shown in "BwA". So every number stands for some certain movement in the company. For the evaluation I care just about the "261". Now I want to find the Material that have a 261 in "-" AND in "+". All the other Material that have a 261 in either "+" OR "-" should not be displayed. I tried it in DAX but can't figure out how to do it.

 

Thanks in advance 🙂

 

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Laura1996 

1. Place Table1[Material] in a table visual

2. Create this measure

 

ShowMeasure =
VAR hasPlus_ = CALCULATE(COUNT(Table1[Material]), Table1[BwA] = 261, Table1[BewertArt] = "+") > 0
VAR hasMinus_ = CALCULATE(COUNT(Table1[Material]), Table1[BwA] = 261, Table1[BewertArt] = "-") > 0
RETURN
IF( hasPLUS_  && hasMinus_, 1,0)  

 

Note that if Table1[BwA] is of type text instead of whole number, you'll need to use

     Table1[BwA] = "261"

in the code above

3. Apply [ShowMeasure] as a visual filter to the table visual, choosing to show when value is 1

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

6 REPLIES 6
FreemanZ
Super User
Super User

hi @Laura1996 

You may also try to add a Tag column like this:

 

 

Tag = 
VAR _material = [Material]
VAR _list = 
CALCULATETABLE(
    VALUES(TableName[BewertArt]), 
    TableName[Material] = _material
)
RETURN
IF(
    [BwA]=261 &&  COUNTROWS(_list)=2,
    "Yes", "No"
)

 

 

then you can filter any visual with this column. 

 

Hey 🙂 

Thank you for your response - as I discovered some issues with the marked solution I wanted to ask how I can add the "+" and "-" in your formula? 

AlB
Super User
Super User

Hi @Laura1996 

1. Place Table1[Material] in a table visual

2. Create this measure

 

ShowMeasure =
VAR hasPlus_ = CALCULATE(COUNT(Table1[Material]), Table1[BwA] = 261, Table1[BewertArt] = "+") > 0
VAR hasMinus_ = CALCULATE(COUNT(Table1[Material]), Table1[BwA] = 261, Table1[BewertArt] = "-") > 0
RETURN
IF( hasPLUS_  && hasMinus_, 1,0)  

 

Note that if Table1[BwA] is of type text instead of whole number, you'll need to use

     Table1[BwA] = "261"

in the code above

3. Apply [ShowMeasure] as a visual filter to the table visual, choosing to show when value is 1

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Laura1996
Frequent Visitor

Thank you for the fast solution 🙂

This one works for me - however just on the original table. If I use it on the aggreated data (where I have also some "LOOKUPVALUE") it shows me a wrong result. any idea what could cause this?

Thanks a lot 🙂

@Laura1996 

I'll need some more details, ideally some sample data, of where it does not work. I do not understand what you mean

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Laura1996
Frequent Visitor

I found the mistake - PowerBI was automatically summing up the numbers, which I didn't wanted. Spend some time searching for the mistake, adapted further and now everything works. Thank you so much for the solution & the offer to help 🙂

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors