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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
woolf
Frequent Visitor

How to GroupyBy to keep filtered values

Hi, I'm fighting with GroupBy/Summarize. I've a imported table with Category, Region, Market, ProductId. I want to filter the table in the dashboard to see the available products in the different shops.

 

As Examples it should deliver the results:

Example 1: Nothing is selected; number of availble products in total -> COUNTA =7
Example 2: Spain is selected; number of availble products in Spain -> COUNTA = 4
Example 3: Spain AND Shop A is selected; number of available products in Shop A -> COUNTA= 2

 

But my formula isn't working. I didn't get the expected result.

GroupBy('ImportedTable','ImportedTable'[Category],'ImportedTable'[Region],'ImportedTable'[Shop],'ImportedTable'[ProductID],"Count",CountAX(CurrentGroup(),'ImportedTable'[ProductID]) 

 

How can i solve it or handle it. Thanx in advance.

 

CategoryRegionShopProductId
PCSpainShop A1574498
PCSpainShop A1574498
PCSpainShop B1574498
PCSpainShop C1574498
PCGermanyShop D1574498
PCItalyShop D1574498
PCNetherlandsShop E1574498
3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@woolf COUNTA( 'Table'[ProductId] ) See PBIX attached below signature.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanx for the quick answer! For showing the numbers it's works perfect. But how can I implement an additional criteria. "Based on the current active filters show me stocks smaller 1 (Order now) and greater 2 (No further action)."

 

I've two measures now. Count_1 = COUNTA( 'Table'[ProductId] ) and a second one Count_2 = IF([Count_1]=1,"Order now","No further action")

 

Why I need it based on the filters? If I've 4 pieces in Spain, I can check the different shops and I've to identify is there a Shop with more then 2 pieces and I can shift it from to another. 

 

That was the reason why I tried it with new table but the filtered values were not available.

StockCompare=ADDCOLUMNS(GROUPBY('ImportedTable','ImportedTable'[ProductID],"Cnt.",COUNTAX(CURRENTGROUP(),'ImportedTable'[ProductID])),"Stock",IF([Cnt.]=1,"Order now","No further action"))

 

ProductIdCount_1Count_2
15744982No further action
15745361Order now
15746411Order now
15746592No further action
15746691Order now
15756121Order now
15756792No further action
15756931Order now
Anonymous
Not applicable

Hi @woolf ,

 

You can do this by simply using an if statement:

vtianyichmsft_0-1725343938990.png

Measure 2 = IF([Measure]=1,"order now","No further action")

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.