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

Get distinct count of "ID's" when comparing a column with itself (based on Slicer selections)

Hi

 

 

I have a table which have 2 columns. "Month" Column (Jan-Dec) & "ID" column (contain duplicates). There are 2 month slicers , "Month1" slicer contains "Jan-June", "Month2" slicer contains "July - Dec". I want to create a measure. If I select "Feb" from Month1 slicer & "October" from Month2 slicer,

then Measure need to comprae "Feb" ID's with "October" ID's and gives distinct "count" of ID's which are not not matches (those ID's present in "Feb" month and are not present in "october" month ). 

Thank you in advance.

regards
Rajkumar

2 ACCEPTED SOLUTIONS
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a table as slicer.then create a measure.

Slicer = SUMMARIZE( SUMMARIZE('Table',[Date],"Date1",EOMONTH([Date],0),"Month",FORMAT([Date],"mmm")),[Date1],[Month])

Then create the measures.

comprae = //CALCULATE(COUNT([Id]),FILTER('Table',FORMAT([Date],"mmm") in ALLSELECTED(Slicer[Month])))
var _min=SUMMARIZE(FILTER('Table',EOMONTH([Date],0) = MIN('Slicer'[Date1])),[Id])
var _max=SUMMARIZE(FILTER(ALL('Table'),EOMONTH([Date],0) = MAX('Slicer'[Date1])),[Id])
return  COUNTROWS(_min)-COUNTROWS(_max)
distinct = 
var _min=SUMMARIZE(FILTER('Table',EOMONTH([Date],0) = MIN('Slicer'[Date1])),[Id])
var _max=SUMMARIZE(FILTER(ALL('Table'),EOMONTH([Date],0) = MAX('Slicer'[Date1])),[Id])
return  COUNTROWS( EXCEPT(_min,_max))

The final output is shown below:

vyalanwumsft_0-1649729175357.png

vyalanwumsft_1-1649729189505.png


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

View solution in original post

Anonymous
Not applicable

HI v-yalanwu-msf,

Thank you so much for reply. Except slicer selection everything is perfect.

In my data , I have month column (only month names, Jan-Dec) and ID Column (with duplicates). As per requirement , i need to create 2 month slicers. Slicer1 contains Jan-Jun , Slicer2 contains Jul-Dec. Requirement is , based on 2 slicers selection (Example: Slicer1: Feb, Slicer2: Oct) Measure have to compare February ID's with October ID's and give Distinct Count which are not matches (that means, ID's present in February month and are not present in October month)



v-yalanwu-msf : instead of one slicer, create measure based on 2 slicer selection.

Thank you in advance.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a table as slicer.then create a measure.

Slicer = SUMMARIZE( SUMMARIZE('Table',[Date],"Date1",EOMONTH([Date],0),"Month",FORMAT([Date],"mmm")),[Date1],[Month])

Then create the measures.

comprae = //CALCULATE(COUNT([Id]),FILTER('Table',FORMAT([Date],"mmm") in ALLSELECTED(Slicer[Month])))
var _min=SUMMARIZE(FILTER('Table',EOMONTH([Date],0) = MIN('Slicer'[Date1])),[Id])
var _max=SUMMARIZE(FILTER(ALL('Table'),EOMONTH([Date],0) = MAX('Slicer'[Date1])),[Id])
return  COUNTROWS(_min)-COUNTROWS(_max)
distinct = 
var _min=SUMMARIZE(FILTER('Table',EOMONTH([Date],0) = MIN('Slicer'[Date1])),[Id])
var _max=SUMMARIZE(FILTER(ALL('Table'),EOMONTH([Date],0) = MAX('Slicer'[Date1])),[Id])
return  COUNTROWS( EXCEPT(_min,_max))

The final output is shown below:

vyalanwumsft_0-1649729175357.png

vyalanwumsft_1-1649729189505.png


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

Anonymous
Not applicable

HI v-yalanwu-msf,

Thank you so much for reply. Except slicer selection everything is perfect.

In my data , I have month column (only month names, Jan-Dec) and ID Column (with duplicates). As per requirement , i need to create 2 month slicers. Slicer1 contains Jan-Jun , Slicer2 contains Jul-Dec. Requirement is , based on 2 slicers selection (Example: Slicer1: Feb, Slicer2: Oct) Measure have to compare February ID's with October ID's and give Distinct Count which are not matches (that means, ID's present in February month and are not present in October month)



v-yalanwu-msf : instead of one slicer, create measure based on 2 slicer selection.

Thank you in advance.

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.