cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Dax on filtering duplicates and counting with text

Hi, I am struggeling with thefollowing table format:

 

Control NumberTitle
PPG-E0001A
PPG-E0001A
PPG-E0002C
PPG-E0002C
PPG-E0002C
PPG-A0001F
PPG-A0001F
PPG-A0001F
PPG-C0001I

 

I want to use a Dax function in order to do the following things:

 

1. Count only unique values of the Row Control Number (Not duplicates)

2. After that I want to be able count only the values which include for example "C" or "A" or "E"

 

At the end I should get a measure for example for "PPG-E" =  2 

 

I ve tried with DISTINCTCOUNT function but didnt get it.

 

To be honest I am a beginner with Power BI and would appreciate any help for this problem.

 

Thx for ur help

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Anonymous
Not applicable

Re: Dax on filtering duplicates and counting with text

 Hi @Yarisch77 

 

this will take whole two months in account. 

It will take last date from previous month to today.

 

I think your requirement is same day from last month to today.

 

I have provided answer for the same.

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

View solution in original post

13 REPLIES 13
Highlighted
Super User VI
Super User VI

Re: Dax on filtering duplicates and counting with text

Hi @Yarisch77 

if i understand you correct

try measures:

1.

unique values = CALCULATE(DISTINCTCOUNT(Table[Control Number]))

2.

unique values by Title = CALCULATE(DISTINCTCOUNT(Table[Control Number]), ALLEXCEPT(Table, Table[Title]))

 

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Highlighted
Frequent Visitor

Re: Dax on filtering duplicates and counting with text

Hi,

 

Thx for ur quick reply.  This goes into a good direction. I took ur idea and played around a little. AFter a while I got this:

 

Measure = CALCULATE(DISTINCTCOUNT('Table'[Control Number]);SEARCH("A";'Table'[Control Number];;-1)>0)
 
This worked well without counting duplicates and only counting with letter "E". Now I added 2 more rows with additional Infos => "Date" and "Status". The idea is to follow the above Measure but put two conditions: 
 
1. if "Date" is between for example "01.01.2019 and 20.01.2019"
2. and if "Status" is for example "Completed"
 
Thx in advance for ur help
Highlighted
Anonymous
Not applicable

Re: Dax on filtering duplicates and counting with text

Hi @Yarisch77 

Measure = CALCULATE(DISTINCTCOUNT('Table'[Control Number]),filter(table,SEARCH("A";'Table'[Control Number];;-1)>0 && table[date]>=date(2019,1,1) && table[date]<=date(2019,1,1) && table[Status]="Completed"))

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Highlighted
Frequent Visitor

Re: Dax on filtering duplicates and counting with text

Hey,

 

Great formula, but it gave me a syntax error. Here's is the adapted formula with the original values from my company, may u see the error:

 

Measure 2 = CALCULATE(DISTINCTCOUNT('CPro Server'[Control Number]);filter('CPro Server'SEARCH("A";'CPro Server'[Control Number];;-1)>0 && 'CPro Server'[Action Request Due Date]>=date(2019;1;1) && 'CPro Server'[Action Request Due Date]<=date(2019;1;1) && 'CPro Server'[Status]="Completed"))
 
Thx in advance for ur help

 

Highlighted
Anonymous
Not applicable

Re: Dax on filtering duplicates and counting with text

Could you share what syntax error you got?

 

It may be some syntax issue like missing closing parenthesis or comma.

 

Thanks,

Pravin

Highlighted
Frequent Visitor

Re: Dax on filtering duplicates and counting with text

It says....

 

Wrong Syntax für "SEARCH".(DAX(CALCULATE(DISTINCTCOUNT('CPro Server'[Control Number]),filter('CPro Server'SEARCH("A",'CPro Server'[Control Number],,-1)>0 && 'CPro Server'[Action Request Due Date]>=date(2019,1,1) && 'CPro Server'[Action Request Due Date]<=date(2019,1,1) && 'CPro Server'[Status]="Completed"))).)

Highlighted
Anonymous
Not applicable

Re: Dax on filtering duplicates and counting with text

Hi @Yarisch77 

 

you have missed comma (,) after table name in filter section.

 

Try to write dax by yourself step by step so that you will get know more about issue.

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Highlighted
Frequent Visitor

Re: Dax on filtering duplicates and counting with text

Hey,

 

Thx a lot , works perfect now. Just one last question:

 

If i am going from this...

 

Measure 2 = CALCULATE(DISTINCTCOUNT('CPro Server'[Control Number]);filter('CPro Server';SEARCH("A";'CPro Server'[Control Number];;-1)>0 && 'CPro Server'[Action Request Due Date]>=date(2019;1;1) && 'CPro Server'[Action Request Due Date]<=date(2019;12;1) && 'CPro Server'[Status]="Completed"))
 
...and instead to define a date range I want to specify for example "last 30 days from today" or "comming 90 days from today", how do I do that???
 
Thx a lot in advance
Highlighted
Anonymous
Not applicable

Re: Dax on filtering duplicates and counting with text

Hi @Yarisch77 

 

Last 30 days or 1 month = CALCULATE(DISTINCTCOUNT('CPro Server'[Control Number]);filter('CPro Server';SEARCH("A";'CPro Server'[Control Number];;-1)>0 && 'CPro Server'[Action Request Due Date]>=dateadd(today(),-1,month) && 'CPro Server'[Action Request Due Date]<=Today() && 'CPro Server'[Status]="Completed"))

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

 

Helpful resources

Announcements
Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Upcoming Events

Community Summit North America – Join Online!

Join this community-driven Power Platform digital event for unbiased support and problem-solving.

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Top Solution Authors