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
ehrreich21
Helper I
Helper I

Filter out data between to sizes

I have a very large CSV data set with length, width, and height, columns, I am trying to filter out the data that will only fit between my criteria below.  I want to narrow my master list down to the only item that will fit in the below sizes. It should also be noted that length width and height are just users entered, so they could interrupt what they think is length width and height, so the flexibility of having it look at those 3 column column to make sure they fit.

  • Smallest Box: 8.26"L x 7.87W x .4"H
  • Largest Box: 21"L x 13.4"W x 11.4"H

Any help would be greatly appreciated

1 ACCEPTED SOLUTION

@ehrreich21 - I fixed the duplicates issue I believe and corrected a syntax error. PBIX is attached for reference, Table 16 (below sig)

Column = 
  VAR __Table = { [Length], [Width], [Height] }
  VAR __Length = MAXX(__Table,[Value])
  VAR __Height = MINX(__Table,[Value])
  VAR __Width = SWITCH(TRUE(),
    COUNTROWS(FILTER(__Table,[Value] = __Length))>1,__Length,
    COUNTROWS(FILTER(__Table,[Value] = __Height))>1,__Height,
    MAXX(FILTER(__Table,[Value] <> __Length && [Value] <> __Height),[Value])
    )
RETURN
  SWITCH(TRUE(),
    __Length <= 8.26 && __Height <= .4 && __Width <= 7.87,"Small",
    __Length <= 21 && __Height <= 11.4 && __Width <= 13.4,"Large",
   "Does not fit"
  )

  


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

@ehrreich21  - Maybe something like:

 

Column = 
  VAR __Table = { [Length], [Width], [Height] }
  VAR __Length = MAXX(__Table,[Value])
  VAR __Height = MINX(__Table,[Value])
  VAR __Width = MAXX(FILTER(__Table,[Value] <> __Length && [Value] <> __Height),[Value])
  SWITCH(TRUE(),
    __Length <= 8.26 && __Height <= .4 && __Width <= 7.87,"Small",
    __Length <= 21 && __Height <= 11.4 && __Width <= 13.4,"Large",
   "Does not fit"
  )

There's a problem to be solved for duplicate values.

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

My table column are labeled UOM_LENGHT, UOM_Height, and UOM_WIDTH, do I just swap that out in our text below for all the places it shows?

@ehrreich21 - I fixed the duplicates issue I believe and corrected a syntax error. PBIX is attached for reference, Table 16 (below sig)

Column = 
  VAR __Table = { [Length], [Width], [Height] }
  VAR __Length = MAXX(__Table,[Value])
  VAR __Height = MINX(__Table,[Value])
  VAR __Width = SWITCH(TRUE(),
    COUNTROWS(FILTER(__Table,[Value] = __Length))>1,__Length,
    COUNTROWS(FILTER(__Table,[Value] = __Height))>1,__Height,
    MAXX(FILTER(__Table,[Value] <> __Length && [Value] <> __Height),[Value])
    )
RETURN
  SWITCH(TRUE(),
    __Length <= 8.26 && __Height <= .4 && __Width <= 7.87,"Small",
    __Length <= 21 && __Height <= 11.4 && __Width <= 13.4,"Large",
   "Does not fit"
  )

  


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@ehrreich21 - Yes, just the first line is where you would swap out [Length], [Height] and [Width].


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I get errors when I use this:

Column =
VAR __Table = { [UOM_Length], [UOM_Width], [UOM_Height] }
SWITCH(TRUE(),
MAXX(__Table,[Value]) <= 8.26 && MINX(__Table,[Value]) <= .4 && MAXX(FILTER(__Table,[Value] <> MAXX(__Table,[Value]) && [Value] <> MINX(__Table,[Value]),[Value]) <= 7.87,"Small",
MAXX(__Table,[Value]) <= 21 && MINX(__Table,[Value]) <= 11.4 && MAXX(FILTER(__Table,[Value] <> MAXX(__Table,[Value]) && [Value] <> MINX(__Table,[Value]),[Value]) <= 13.4,"Large",
"Does not fit"
)

@ehrreich21 - Yes, because I had a syntax error, try this:

 

Column = 
  VAR __Table = { [UOM_Length], [UOM_Width], [UOM_Height] }
  VAR __Length = MAXX(__Table,[Value])
  VAR __Height = MINX(__Table,[Value])
  VAR __Width = SWITCH(TRUE(),
    COUNTROWS(FILTER(__Table,[Value] = __Length))>1,__Length,
    COUNTROWS(FILTER(__Table,[Value] = __Height))>1,__Height,
    MAXX(FILTER(__Table,[Value] <> __Length && [Value] <> __Height),[Value])
    )
RETURN
  SWITCH(TRUE(),
    __Length <= 8.26 && __Height <= .4 && __Width <= 7.87,"Small",
    __Length <= 21 && __Height <= 11.4 && __Width <= 13.4,"Large",
   "Does not fit"
  )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors