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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
gracie494
Helper I
Helper I

Dax - Count in Column based on a specific field

Hello, How do I perform a count of the Cons group in each specific reporting unit. The output I am trying to achieve is in green:

gracie494_0-1628515374187.png

 

1 ACCEPTED SOLUTION

@gracie494 

pls add all(), and have a try on below DAX.

calculate(distinctcount[consgroup],filter(ALL(table),[reportingunit]=max([reportingunit]))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

9 REPLIES 9
ryan_mayu
Super User
Super User

@gracie494 

maybe try

calculate(distinctcount[consgroup],filter(table,[reportingunit]=max([reportingunit]))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu sadly it didnt work, just returns a 1

gracie494_0-1628519245489.png

 

@gracie494 

pls add all(), and have a try on below DAX.

calculate(distinctcount[consgroup],filter(ALL(table),[reportingunit]=max([reportingunit]))





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu Thank you so much, it worked. 🙂

 

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Greg_Deckler
Super User
Super User

@gracie494 Perhaps:

Measure =
  VAR __RU = MAX('Table'[Reporting Unit])
  VAR __CG = MAX('Table'[ConsGroup])
RETURN
  COUNTROWS(FILTER(ALL('Table'),[Reporting Unit]=__RU && [ConsGroup]=__CG))

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks Greg, sadly it did'nt work. Below is the result

 

gracie494_0-1628517228450.png

 

amitchandak
Super User
Super User

@gracie494 , Try

a New column

= calculate(distinctcount(Table[ConsGroup]), filter(Table, [ reporting unit] =earlier([ reporting unit])))

@amitchandak Thanks, though sadly it didnt work

gracie494_1-1628517372496.png

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.