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

Need Help with Filter & Calculate in Dax

Hi Everyone,

I'm trying to write a DAX expression in the pivot table and I could not figured out how to use the combination of Calculate, Filter & Count.

 

I need to exclude all User that has 1 or less transaction - I currently have this expression but the result is not correct: 

 

 

=if(
count([Type]) > 1, COUNT([Type]), 
blank())

 

 

 

The Data is as follows:

DepartmentUserSymbolType
A1AAATSLABuy
A1AAATSLABuy
A1CCCBCEBuy
A1DDDPWCBuy
B1AAAHBTSell
B1BBBBCEBuy
B1BBBHDSSell

 

Output should be, note User "CCC" & "DDD" are not populated because it has only 1 count:

DepartmentUserTypeSymbolCount
A1AAABuyTSLA2
  SellHBT1
B1BBBBuyBCE1
  SellHDS1

 

Hope you can help!

 

2 REPLIES 2
Anonymous
Not applicable

[Exclude User] =
var __userFiltered = ISFILTERED( Data[User] )
var __oneUserVisible = HASONEVALUE( Data[User] )
var __totalTranCount =
	CALCULATE(
		COUNTROWS( Data ),
		ALLEXCEPT( Data, Data[User] )
	)
var __shouldExclude = __totalTranCount <= 1
var __finalCondition =
	__userFiltered
	&& __oneUserVisible
	&& __shouldExclude
return
	if( __finalCondition, __shouldExclude )

This measure tells you if you should exclude the user (TRUE) or not (FALSE). You can put this measure in your pivot and filter by it leaving only those users for which the measure returns FALSE (meaning: don't exclude).

 

Best

D

Greg_Deckler
Community Champion
Community Champion

Maybe:

 

Measure =
  VAR __Table = 
    SELECTCOLUMNS(
      FILTER(
        SUMMARIZE(
          ALL('Table'),
          [User],
          "__Count',COUNTROWS('Table')
        ),
        [__Count] < 2
      ),
      "User",
      [User]
    )
RETURN
  IF(MAX('Table'[User] IN __Table,0,1)

 

Then use that as a filter.



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...

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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