cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Helper II

## Help with Distintcount logic

I have the following table:

This table is basically capturing whether a job is finished or not.  I am displaying the job vs date graph below:

In this graph, I would like to display a tooltip such that:

- It should display a distinct count of the finishNumber column based on whether the task is complete or not complete.

For instance, on 3/1/2017, I have 2 completed tasks and one uncompleted task. The uncompleted tasks do not have finishNumber. So, in my bar graph, when I hover over the red area, the distinct count of finishNumber for the two completed tasks should be 2 ( since 14 and 16 are distinct). And if i hover over the black area, the distinct count should be zero (since there is no finishNumber for the very first record).

How can I accomplish this?  I am not sure what logic to implement and whether it should be a measure or a column?

Would appreciate any help.

1 ACCEPTED SOLUTION
Community Champion
```Distinct Count Measure =
CALCULATE (
DISTINCTCOUNT ( 'Table'[finishNumber] ),
FILTER ( 'Table', 'Table'[finishNumber] <> BLANK () )
)
+ 0```

Add plus zero - it just forces the zero to show!

10 REPLIES 10
Community Champion

@sieed

This is what I would do...

Create this Measure (you can rename it something better)

`Distinct Count Measure =CALCULATE (    DISTINCTCOUNT ( 'Table'[finishNumber] ),    FILTER ( 'Table', 'Table'[finishNumber] <> BLANK () ))`

And then setup your Chart like in the picture below

Date on Axis, AppID in the Legend, Measure in the Value

(right-click on AppID in the Legend as check - Show Items with No Data)

Hope this helps!

Super User

Since he already have IsFinished flag, no need to calculate a measure assuming each job will have one record:

- Put date on the axi

- IsFinished on legent

- Cound Job Id on value

and it will do the job, no?

Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤

Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Community Champion

Use my Measure from above in the Tooltips!

It will show up only for true!

Helper II

@Sean, what do I do if I also want to diaply the distincount of 0 ?

Community Champion
```Distinct Count Measure =
CALCULATE (
DISTINCTCOUNT ( 'Table'[finishNumber] ),
FILTER ( 'Table', 'Table'[finishNumber] <> BLANK () )
)
+ 0```

Add plus zero - it just forces the zero to show!

Helper II

Thanks @Sean

Super User

@sieed what I mentioned will work, make sure you have IsFinished on Legend. No sure why there is a need to calculate a measure when you already have IsFinished to seperate between finished and non-finished jobs. Also it is assuming that you will unique finish number. It is always good to provide little context about the dataset so that better solution can be provided.

THanks,

Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤

Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Community Champion

@parry2kWhat do you propose we drag to the tooltips? And how will you make it show zero on False?

And BTW my measure would work with COUNTA not only DISTINCTCOUNT because EACH Column represents an APP

However here's why I used DISTINCTCOUNT - this is from the original question...

"the distinct count of finishNumber for the two completed tasks should be 2 ( since 14 and 16 are distinct)"

Helper II

@parry2k, I am trying to find the ditinct count of "finishNumber" based on whether a task is completed or not for that particular date.

For instance, on 3/12017, I have three tasks, two of which are complete. Moreover, these two completed tasks have different "finishNumber".  so, the distinct count should be 2 on the tool tip. Also, for the same bar on the same date, the black area (the area representing the record which is not complete) should show distinct count of zero since there is no "FinishNumber" for that record.

Helper II

@Sean,  the legend is the "IsFinished" column, not the AppID.  That's the chellenging part.

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

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

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors