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
holodan95
Helper II
Helper II

Counting rows, that are filtered with matrix table

Hello All,


I'm currently having some trouble with counting rows in a matrix visual, that fit to my true/false criteria.

It's very simple. If X-Y  >= 1 than "in stock" else "oos". If this function = "in stock", then count it.

Let's say I have 5 companies, with 1000 items, some of their items are in stock, some are not. ( stock quantity for the item is >= 1, then it's "in stock")

 

I have a matrix with the following hierarchy:

Row1-Company name
Row2-Item code
Value1--Total sales (measure)
Value2--Out of stock info

 

What I need, is the number of out of stock products as Value2, when the hierarchy is closed, so I can see how many products are out of stock. Opening down Row1, I should see the products analitically.

 

When I make a measure for this, It says that I cannot make a true/false statement in the measure..

 

Please help me with this.

 

Thank you!

 

 

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @holodan95 ,

 

This is my test table:

vyadongfmsft_0-1667184492741.png

 

Create a new column:

In/Out stock = IF('Table'[Quantity] >= 1, "in stock","oos")

vyadongfmsft_1-1667184544979.png

 

Create two measures:

Total sales = SUM('Table'[Sales])

Out of stock info = 
var count_stock = CALCULATE(COUNT('Table'[In/Out stock]),FILTER('Table','Table'[In/Out stock] = "oos"))
return
IF(count_stock >= 1, count_stock,0)

 

Create a matrix visual, is this the result you want?

vyadongfmsft_2-1667184664486.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
holodan95
Helper II
Helper II

Hi @v-yadongf-msft 

 

This will not work in my riport, because the information I try to filter to, comes from a measure in stock/oos as a true or false value, and not from a table. I cannot make a new column for it, for technical reasons.

 

What I need is a measure that can calculate the number of true or false statements, so I can put that into a matrix.

@v-yadongf-msft 

In summary, I need a measure, which counts the number of TRUE values in an IF function like this:

Measure_1 = IF(stock <= 0 , "True" , "Fales")

Measure_2 = CALCULATE(DISTINCTCOUNT(Stock_table, Stock_table[item_name]),Measure_1 = "true")

--> so practically Measure_2, put into a matrix visual, should add up all those distinct items, that we have <= 0 in stock.

 

Please note, that it is not possible to make another column in the source table, as it is more complicated than the one in example.

Hi @holodan95 ,

 

Can you share with me some screenshots of your data after hiding sensitive information, the measure formula and  tell me what's your expected output?

 

Best regards,

Yadong Fang

Hello,

 

I managed to make a working solution using your method, so I'll accept it as a solution, however it's still a myth for me how to count the number of true or false values of a measure, inside a measure.

 

Thank you for you help!!

v-yadongf-msft
Community Support
Community Support

Hi @holodan95 ,

 

This is my test table:

vyadongfmsft_0-1667184492741.png

 

Create a new column:

In/Out stock = IF('Table'[Quantity] >= 1, "in stock","oos")

vyadongfmsft_1-1667184544979.png

 

Create two measures:

Total sales = SUM('Table'[Sales])

Out of stock info = 
var count_stock = CALCULATE(COUNT('Table'[In/Out stock]),FILTER('Table','Table'[In/Out stock] = "oos"))
return
IF(count_stock >= 1, count_stock,0)

 

Create a matrix visual, is this the result you want?

vyadongfmsft_2-1667184664486.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.