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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
RA_gov
Frequent Visitor

Is it possible to add counts next to slicer field?

How would I add a 'count' of the slicer values as an additional field in the slicer?
I have a map report with properties in US states.  My current slicer is STATE.
I want to add the count of properties in each STATE on my slicer to assist my users.  I need guidance on how to do this.

What I am looking to do:

[check box]   AK  4
[check box]   AL  7
[check box]   AZ  2
[check box]   CA  9

 

Thanks.

3 ACCEPTED SOLUTIONS

Hi @RA_gov,

 

Replace the ";" by "," depending on the regional settings PBI (as EXCEL) uses the dot comma or the comma to make the split between formulas parameters.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

RA_gov
Frequent Visitor

@MFelix

State Count = Table1[state_code] & "  "
    & CALCULATE ( COUNT ( Table1[state_code] ), ALLEXCEPT (Table1, Table1[state_code]  ) )

 

This format works!  commas replacing semicolons for US based regional setting.

 

Thank you.  Well done.

View solution in original post

Hi @RA_gov,

 

Maybe formatting the number as 0000:

 

State Count = Table1[State] & " " & FORMAT(CALCULATE ( COUNT ( Table1[State] ); ALLEXCEPT ( Table1; Table1[State] ) );"000#")

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

7 REPLIES 7
MFelix
Super User
Super User

Hi @RA_gov,

 

You need to add an addtional column to your model that calculates the number of values and concatenate with the State. Be aware that this is not dinamic and the count is based on the full data.

 

State Count =
Table1[State] & " "
    & CALCULATE ( COUNT ( Table1[State] ); ALLEXCEPT ( Table1; Table1[State] ) )

 

Then use this new column in the slicer.

 

If you have a states dimension table that is related with the other table add the column in that table with the following code:

Column = States[State] &" " &CALCULATE(COUNT(Table1[State]))

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



RA_gov
Frequent Visitor

@MFelix

 

When I remove the semicolons ';' and the ALLEXCEPT clause, my counts for each STATE =1.

When I insert your text as written, I get:

The syntax for ';' is incorrect. (DAX(dbo_active_property[state_code] & " " & CALCULATE ( COUNT ( dbo_active_property[state_code] ); ALLEXCEPT ( dbo_active_property; dbo_active_property[state_code] ) ))).

 

Any hints?


Thanks

RA_gov
Frequent Visitor

@MFelix

State Count = Table1[state_code] & "  "
    & CALCULATE ( COUNT ( Table1[state_code] ), ALLEXCEPT (Table1, Table1[state_code]  ) )

 

This format works!  commas replacing semicolons for US based regional setting.

 

Thank you.  Well done.

Hi @RA_gov,

 

Replace the ";" by "," depending on the regional settings PBI (as EXCEL) uses the dot comma or the comma to make the split between formulas parameters.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



RA_gov
Frequent Visitor

Your solution works.  The numbers however are not 'right justified' so it appears a bit confusing to the viewer.

AK 73

AL 537

AR 432

AZ 320

CA 2259

 

Do you have a recommendation to make it appear like this:

AK       73

AL     537

AR    432

AZ    320

CA  2259

 

Thanks,

Hi @RA_gov,

 

Maybe formatting the number as 0000:

 

State Count = Table1[State] & " " & FORMAT(CALCULATE ( COUNT ( Table1[State] ); ALLEXCEPT ( Table1; Table1[State] ) );"000#")

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



RA_gov
Frequent Visitor

@MFelix

Good solution.  Not perfect, but looks much better to viewer.
Thanks

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.