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

columns and tables

hi everyone, 

i have the following table provided.

 

image.png

every material should have a unique material number. If there are more than one material number for a material, a table like  the following table should inform the user

 

image.png

 

thanks in advance

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Perhaps something like:

 

Measure = 
VAR __table = SUMMARIZE('Table',[Material],[MaterialNumber])
RETURN
COUNTROWS(__table)

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

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Perhaps something like:

 

Measure = 
VAR __table = SUMMARIZE('Table',[Material],[MaterialNumber])
RETURN
COUNTROWS(__table)

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

@Greg_Deckler  Thanks it works!

I am trying to understand the solution. Why does it work. 

Summarize actually return a table with two columns: Material and MaterialNumber.  

So the COUNTROWS( ) function counts the rows of the first column of the VAR __table?

Well, it works because SUMMARIZE returns distinct results for each summarized column. So, because you are summarizing by 2 columns, you are essentially going to get back a table with all of the distinct combinations of those two columns. Now, in the context of having material, this means that any material that has 2 material numbers will return 2 rows, because there are 2 unique material numbers for that material. However, if you put this measure in the context of material and material number, I don't think it would work necessarily.


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

Read my blog last week. Towards the end I show you how to do this in Power Query. 

https://exceleratorbi.com.au/preventing-managing-refresh-failures-in-power-bi/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.