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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

DAX - Help

Hi,

 

Have a table with the following format

 

 

Adnumber  Title Name

001               Bob

001               Fred

002               Bob

 

I want to be able to have a measure which counts the number of adnumbers with two titles

 

And then to do something like

 

something like  

calculate(count(adnumber),count(title name)=2)

 

so 001 = 2 , 002=1

 

Thanks

 

Chris

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Anonymous,

 

You can try to use below formula to get the different count of year group.

Summary table =
SUMMARIZE (
    ADDCOLUMNS ( Table, "Year", YEAR ( table[Date] ) ),
    [Year],
    "Count Titile", DISTINCTCOUNT ( Adnumber[Title] ),
    "Count AD", DISTINCTCOUNT ( Adnumber[Adnumber] )
)

 

Regards,

Xiaoxin Sheng

View solution in original post

Hi @Anonymous,

 

Create a calendar table and extract year from the data column of the calendar table using the YEAR() function.  Create a relationship from the Date column of your data table to the date column of your calendar table.  Drag year from the calendar table to the visual or as a silcer or to the filter section.  Select a particular year.  Now use the IDSTINCTCOUNT() function.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
Greg_Deckler
Community Champion
Community Champion

Table 4 = SUMMARIZE(Adnumber,Adnumber[Adnumber],"Number",DISTINCTCOUNT(Adnumber[Title]))


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

Hi @Greg_Deckler,

 

Thanks for getting back..

 

Thats brilliant... How would I add a where clause into that?

 

Thanks

 

Chris

Would depend on where you want the where clause but you could do something like:

 

Table 4 = SUMMARIZE(Adnumber,Adnumber[Adnumber],"Number",CALCULATE(DISTINCTCOUNT(Adnumber[Title]),FILTER(Table,Criteria)))

Basically, wrap your DISTINCTCOUNT in a CALCULATE and add a FILTER clause.



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

Thanks @Greg_Deckler,

 

I got it to work ok

 

Table 4 = SUMMARIZE(Query1,Query1[adnumbr],"Number",CALCULATE(DISTINCTCOUNT(Query1[ttlcode]),Query1[ttlcode]="ENS" || Query1[ttlcode]="CN" || Query1[ttlcode]="WN" || Query1[ttlcode]="TS" || Query1[ttlcode]="HC" || Query1[ttlcode]="NWEM", YEAR(Query1[dateins] = 2017)))

but the year part doesnt seem to do anything?

I'd need sample data to replicate.



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

 @Greg_Deckler

 

Adnumber  Title Name Date

001               Bob              01/05/2017

001               Fred             01/06/2017

002               Bob              01/02/2016

 

So it would return where year is 2017

 

Number of Ads     Number of Titles

1                             2

 

Thanks 

 

 

 

Hi @Anonymous,

 

Create a calendar table and extract year from the data column of the calendar table using the YEAR() function.  Create a relationship from the Date column of your data table to the date column of your calendar table.  Drag year from the calendar table to the visual or as a silcer or to the filter section.  Select a particular year.  Now use the IDSTINCTCOUNT() function.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @Anonymous,

 

You can try to use below formula to get the different count of year group.

Summary table =
SUMMARIZE (
    ADDCOLUMNS ( Table, "Year", YEAR ( table[Date] ) ),
    [Year],
    "Count Titile", DISTINCTCOUNT ( Adnumber[Title] ),
    "Count AD", DISTINCTCOUNT ( Adnumber[Adnumber] )
)

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors