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
Anonymous
Not applicable

Count items in a column based on another column

Hi All,

 

I have calculated the Gross Margin % using Price and Cost value by Item vise.

Every Item having the Upper bound and lower bound, to calculate the Margin violation, as below

 

Margin.png

 

 

My Issue is: I need to count the Items, which Margin% is out of lower and upper bound i.e,

                    count items only if Gross Margin % > UpperBound and Gross Margin% < Lower Bound

                    ignore if the lower and upper bound is blank

 

Any help there? I'm was searching through community posts but nothing worked for me

 

Thanks,

1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

Try this:

Measure =
SUMX(
SUMMARIZE( 
ItemTable , 
ItemTable[ItemNumber] ,
"Value" , IF( OR([Gross Margin %] < ItemTable[Lower Bound] , [Gross Margin %] > ItemTable[Upper Bound]) , 1 , 0 )
) , [Value]
)


/ J


Connect on LinkedIn

View solution in original post

4 REPLIES 4
tex628
Community Champion
Community Champion

Try this:

Measure =
SUMX(
SUMMARIZE( 
ItemTable , 
ItemTable[ItemNumber] ,
"Value" , IF( OR([Gross Margin %] < ItemTable[Lower Bound] , [Gross Margin %] > ItemTable[Upper Bound]) , 1 , 0 )
) , [Value]
)


/ J


Connect on LinkedIn
Anonymous
Not applicable

Hi @tex628,

 

Thank you so much for the solution, It works for me.

 

Thanks,

Atul

amitchandak
Super User
Super User

@Anonymous , you can have two what if parameter Lower and upper

 

and create a measure like 

measure 1 = countx(filter(summarize(table, table[Itemnumber], "_1", [Gross Margin %]), [_1] >=selectedvalue(Lower[Lower]) && [_1] <=selectedvalue(upper[upper])),[Itemnumber])

 

or static value

Measure 2 = countx(filter(summarize(table, table[Itemnumber], "_1", [Gross Margin %]), [_1] >=.1 && [_1] <=.2),[Itemnumber])

 

what-if

https://docs.microsoft.com/en-us/power-bi/desktop-what-if

Anonymous
Not applicable

Hi @amitchandak,

 

Thank you for the solution, but it only shows the Blank every time

 

 

Thanks,

Atul

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.