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
Zarlot531
Helper V
Helper V

Distinct count *only* at a certain level, even if other levels are showing

So i have a dataset that has 4 fields for the last 18 months:

 

Job Type

Job Code 

Part Code 

Part Cost

 

any given job code can be repreated multiple times because any given job can have multiple and various parts. Not all parts show up on each job though.

 

What I ultimately want to do is build a pivot table where I can have job type as an overall filter with part code running down the left side (rows) and have an "average" cost per job as a measure. 

 

BUT.... Power BI wants to only calculate the average of course for when the part codes show up. But... I want overall average meaning total sum of each part divided by total jobs. For what I'm trying to do, Power BI will, for example, if a part only shows up once it'll consider the average that entire cost when realy it should be divided by the number of unique jobs. 

 

But I'd like to be able to filter the overall pivot by job type as well. In other reports, I've had to resort to writing SQL at the server level to get zeros added for every missing part but god that's so dang efficient. Surely there's a better way. Every time I write a countrows or distinct count though, it just does'nt do what I need it to. THanks

 

 

1 ACCEPTED SOLUTION

Silly me... i had the wrong formula field above. This solves it. Capture56.JPG

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

😃



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.

parry2k
Super User
Super User

@Zarlot531 first and foremost, it is much easier to answer if you share sample data with the expected output otherwise it is hard to reply, Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

2nd, it is a best practice to create a star schema, in your case if you have a separate for each job (work as a dimension) it will be very easy to work with. Understand star schema and the importance for Power BI - Power BI | Microsoft Docs

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 



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.

Zarlot531
Helper V
Helper V

Here's the crux of my issue. There are 2,058 unique jobs and I can get to that number using the following formula.

 

But... when I filter on job type, it doesn't adjust. CaptureOct2.JPG

 

 

CaptureOct.JPG

Silly me... i had the wrong formula field above. This solves it. Capture56.JPG

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.