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
jwi1
Post Patron
Post Patron

Filtering data

Hi all,

I hope someone can help me with the following.

below is a small dataset.

I want to set up a filter which gives me only the details of the orders in which ONLY partnr AMS300037 is mentioned.

In this example only order nr 8998429 and 8998478.

As the other orders containts more partnumbers than only AMS300037, these orders must be ignored in this filter.

 

Thanks for your help!

 

This is the set which must be filtered:

Order nrpartnr
8998407AMS300065
8998407AMS300037
8998407AMS900010
8998421AMS300037
8998421AC120043303
8998421AMS900010
8998421120074500SV
8998429AMS300037
8998478AMS300037

 

This must be the outcome of the filter

8998429AMS300037
8998478AMS300037
2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi, @jwi1 

I am not quite sure whether the below picture is what you are looking for.

Please check the sample pbix file's link down below, and the measure.

 

Picture4.png

 

https://www.dropbox.com/s/8s9wmfeebhzoxgg/jwi.pbix?dl=0 

 

Result =
VAR groupbyordernr =
FILTER (
CALCULATETABLE (
GROUPBY (
'Table',
'Table'[Order nr],
"@countpartnr", COUNTX ( CURRENTGROUP (), 1 )
),
ALL ( 'Table'[partnr] )
),
[@countpartnr] = 1
)
RETURN
MAXX ( groupbyordernr, 'Table'[Order nr] )
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Linkedin: https://www.linkedin.com/in/jihwankim1975/

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

Hi @AlexisOlson , Can you help me a little bit further please?

I have changed the formula a bit, I am using the REPAIR CODE now.

This works fine, but now I want to be able to change the repair code, using a slicer.

I have already created a slicer with two repair codes, by using a simple table.


Is it now possible to change the VAR REPAIRCODE?

Meaning, If I click on A03 1 RP 26, the measure must work with this code instead of A01 1 RN 26


Thanks!

 

 

jwi1_1-1618635665663.png

 

jwi1_0-1618636172705.pngjwi1_1-1618636200489.png

 

View solution in original post

11 REPLIES 11
AlexisOlson
Super User
Super User

I would try applying the filter ShowOrder is 1 on your visual where

 

ShowOrder =
VAR partnr = "AMS300037"
VAR ordr = CALCULATE ( SELECTEDVALUE ( Table1[Order] ) )
RETURN
    IF (
        CALCULATE (
            SELECTEDVALUE ( Table1[partnr] ),
            ALL ( Table1 ),
            Table1[order] = ordr
        ) = partnr,
        1,
        0
    )

@AlexisOlson This seems to work fine!

Now I have an additional question: if I want the partnumber to be a variable (via a filter or so), is that also possible?

Sure. Read it in just like I did with ordr.

Hi @AlexisOlson , Can you help me a little bit further please?

I have changed the formula a bit, I am using the REPAIR CODE now.

This works fine, but now I want to be able to change the repair code, using a slicer.

I have already created a slicer with two repair codes, by using a simple table.


Is it now possible to change the VAR REPAIRCODE?

Meaning, If I click on A03 1 RP 26, the measure must work with this code instead of A01 1 RN 26


Thanks!

 

 

jwi1_1-1618635665663.png

 

jwi1_0-1618636172705.pngjwi1_1-1618636200489.png

 

VAR repaircode = CALCULATE ( SELECTEDVALUE ( SRS_repair_codes[2_comm_op....Klant] ) )

Jihwan_Kim
Super User
Super User

Hi, @jwi1 

I am not quite sure whether the below picture is what you are looking for.

Please check the sample pbix file's link down below, and the measure.

 

Picture4.png

 

https://www.dropbox.com/s/8s9wmfeebhzoxgg/jwi.pbix?dl=0 

 

Result =
VAR groupbyordernr =
FILTER (
CALCULATETABLE (
GROUPBY (
'Table',
'Table'[Order nr],
"@countpartnr", COUNTX ( CURRENTGROUP (), 1 )
),
ALL ( 'Table'[partnr] )
),
[@countpartnr] = 1
)
RETURN
MAXX ( groupbyordernr, 'Table'[Order nr] )
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Linkedin: https://www.linkedin.com/in/jihwankim1975/

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Jihwan_Kim 

Thanks, works fine!

AlexisOlson
Super User
Super User

Are you trying to do this in the query editor or with DAX?

Hi @AlexisOlson 

Preferable with DAX, because this is just an example.

If I know how to do this I am planning to make it workable for other partnumbers as well.



OK. How are you using this filter? Are you trying to define a calculated table or is it part of a measure or are you trying to limit what is showing in a visual or what?

I am trying to limit what is showing in a visual. 

If I select a partnumber via a filter, then the visual is only showing me the data as described above.

Thanks for your help so far.

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.