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

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

Reply
jojo6x
Regular Visitor

Adding date column messed up my count

EDIT:

 

I am very new to Power BI and am not a professional coder, so please go easy on me... I have a table visual that lists all procedures performed by my surgeons. I created a slicer with their names so you can choose one of the surgeons and it will give you a count of each type of surgery done by that person. I created a measure using the code below to achieve this. It worked flawlessly until I added the date field so I could also slice by a date range. Now it just gives me a count of each type of procedure performed on individual days. I don't really understand why it is considering the date when calculating since the code doesn't even use the date column. It seems like i need it to not consider the date when counting, but i am not sure if that is the issue and if it is, i don't know how to fix it. 

 

Total-ResidentSurgeon = SUMX(VALUES(rv_resident_surgeon_experience[cpt_code]), CALCULATE(COUNT(rv_resident_surgeon_experience[resident_surgeon])))

 

 

6 REPLIES 6
parry2k
Super User
Super User

You have to be very specific about how you want to visualize and the measure will be done accordingly. If you are adding the date in the visual, now distinct count will be calculated based on the row context. These are the basics of the DAX - row context get transition to filter context.



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.

ok. thank you for the help. i will keep working on it. 

parry2k
Super User
Super User

@jojo6x It is hard to answer without basic data but I guess you want distinctcount of billing code:

 

Distinct Billing Code Count = 
DISTINCTCOUNT ( YourTable[Billing Code Column] )


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.

That works, but doesn't give me a "Total" column where i can see the count, and when i add the date column to the table visual, it does the same thing as before where it gives me a distinct count of each type per day instead of a total per each type. 

jojo6x
Regular Visitor

i am not trying to get a count of all rows. i need a count of each type of procedure. the table has the billing code, procedure description, the person who performed the procedure, and the date of the procedure. 

 

for example... if i choose Smith on my slicer table, i want to see a count of each type of procedure they have done (20 tonsillectomies, 45 ear tubes, etc.). they are identified by the billing code. It was working perfectly until i added the date column to the table visual. Now it gives me a count of each type of procedure they did on each day instead.

 

does that make sense?

parry2k
Super User
Super User

@jojo6x assuming your table has 3 columns,

 

surgeon

date

type of surgery

 

and each row represents a type of surgery done by which surgeon on what date, correct? You can simply add following measure to get the count:

 

Surgery Count = COUNTROWS ( 'Your Table Name' )


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.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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