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
hajoo125
Frequent Visitor

Pulling out distinct values based on multiple criteria

Hello Everyone,

 

Please i need some helping writing some dax function to pull distinct values from a live data feed and based on multiple criteria into a new table. There is a lot of duplicate data that needs to be filtered out. Its a training attendance form and customers are required to undergo just one training on a particular topic per quarter. But we are having customers being recorded multiple times for the same training within the same quarter. 

 

 

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @hajoo125 

Create a measure

Measure = CALCULATE(DISTINCTCOUNT('430'[customers]),ALLEXCEPT('430','430'[quarter],'430'[training]))

Add columns and measures in a matrix visual, you could also expand down all level

3.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Maggie,

 

Thanks for trying to help out. I still haven't gotten this right, can you give me direct syntax for this? What does '430' in your formula mean? See below a snapshot of my report headers in power bi desktop.

 

 

pbi.PNG

 

So i need to extract unique participants id within each quarter on a given set of training modules.

 

Thematic principale = training module

Hi @hajoo125 

"430" is my table name.

if 'table name'[year],'table name'[quarter] are columns, try measure below

Measure = CALCULATE(DISTINCTCOUNT('table name'[participants id]),ALLEXCEPT('table name','table name'[year],'table name'[quarter],'table name'[Thematic principale]))

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Maggie,

 

Thanks so much. This works quite well except that i need the function to stretch its scope across all columns because we have two columns that account for beneficiary ids and two columns for training modules. This present function is scanning a single column of each, how can i expand it please? See below for present function and what the headers in the file look like.

 

Participants = CALCULATE(DISTINCTCOUNT('Sheet1'[Participant ID]),ALLEXCEPT('Sheet1',Sheet1[Year],'Sheet1'[Quarter],'Sheet1'[Thématique Principale]))

 

Table:

test 2.JPG

 

 

Hi Maggie,

 

So i have been inspecting this function deeply and realizing that it might not give me exactly what i want. Check the image below out:

 

testtttt.JPG

 

In the sheet above, we have about 29 rows that shows that beneficiaries have attended multiple trainings and a beneficiary can attend the same training multiple times. There are two columns for beneficiary ids, one for those that came to the training with their registration cards and those who didn't. Also there are two columns for training modules because more than one training module can be taught at any session.

 

To calculate for the number of beneficiaries who have attended a GAP training in a quarter would be the count of the first instance only of each beneficiary that has attended either GEP,GMR or INP. So we do not count duplicates and in the sheet above the correct answer would be 6.

 

6 beneficiaries have attended GAP trainings in the quarter(highlighted in green). 

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.