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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
sarthsla
Frequent Visitor

Count as per Area

Hi All,

I have below data in Table Visual in PBI desktop, where StatusMeasure is generated dynamically based on ID and few conditions

sarthsla_0-1770132444762.png

No when I want to count the Distinct IDs for each Area and Statusmeasure, I try to take off Login from table visual and everyrthing goes blank.

Any idea how to write a DAX for Distinctcount(ID)(on Y-axis) for each Area(on X-axis) with Status measure as legend 

So above should show as below

sarthsla_1-1770132674722.png

Please note StatusMeasure is a dynamically generated DAX based on row level values of Login in table visual and a date.

1 ACCEPTED SOLUTION
sarthsla
Frequent Visitor

Thanks I resolved it by myself with help of DAX using KEEEPFILTERS

View solution in original post

7 REPLIES 7
sarthsla
Frequent Visitor

Thanks I resolved it by myself with help of DAX using KEEEPFILTERS

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file with your measures already written.


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

1) A measure can’t be used as a Legend category

In a column/stacked chart, Legend must be a column (categorical field). A DAX measure (your StatusMeasure) can’t create legend buckets by itself. So if you want “Yes/No” as the legend, you need a real column in the model (calculated column / in the source)

 

2) Your StatusMeasure depends on “Login being in the visual”

That usually happens when the measure uses something like SELECTEDVALUE(Widget[Login]).

When you remove Login from the visual, there are multiple logins in scope, thus, SELECTEDVALUE() becomes blank.So you need to rewrite the logic so it works at the grain you want (Area/ID), not at the grain of the table visual.

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.
GeraldGEmerick
Super User
Super User

@sarthsla To do this, you generally need to use a table with no relationships that has a row for every potential value of your measure. You use that in your legend and then write DAX similar to the following for the distinct count:

 

StatusMeasure Count =
VAR _Legend = MAX( 'Legend Values'[Value] ) // this is your table with no relationships Yes/No
VAR _Table = DISTINCT( SELECTCOLUMNS( FILTER( ADDCOLUMNS( 'Table', "Status Measure", [StatusMeasure] ), [Status Measure] = _Legend ), "ID", [ID] ) )
VAR _Return = COUNTROWS( _Table )
RETURN _Return

 

its showing all counts of IDS but not distinct counts for area

Hi @sarthsla ,


Thank you @cengizhanarslan  for the response provided!

Has your issue been resolved? If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

Thank you.

Hi @sarthsla ,

 

I wanted to follow up and see if you had a chance to review the information shared. If you have any further questions or need additional assistance, feel free to reach out.

Thank you.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.