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
kyleldi
Frequent Visitor

Best Way to Create a percentage by month?

Hello, I'm new to Power BI, and I have a bunch of deliveries in a delivery table that I'm trying to graph with an on time delivery approach.  I've figured out how to use the bin function to group my data together by month, and in turn group my three possible job statuses by status as well, but from there, I do not understand how to write a formula to calculate them.  Ultimately I'm looking to create a graph that shows month and on time delivery percentage.  Any assistance would be gratefully appreciated!

 

Capture.JPG

4 REPLIES 4
Greg_Deckler
Super User
Super User

Could you supply some raw data or sample data and explain how on time is calculated? It sounds like what you want is a measure like:

 

MyPercent = CALCULATE(COUNT([Job]),FILTER(Table,ALLEXCEPT([Shipped_Date],[OTD_Status]))) / CALCULATE(COUNT([Job]),FILTER(Table,ALLEXCEPT([Shipped_Date])))

Something along those lines.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Here is a snapshot of some of the data.  I've used a column (OTD_Status) to calculate whether the ship date was ontime/late/early.  At least that's how I'm used to doing it in MSQuery/Excel.  This is data that comes directly out of our SQL Database.Capture3.JPG

 

 

 

 

 

 

 

 

 

kyleldi
Frequent Visitor

So far the best I have come up with calculates the number of status' that meet the "Early" requirement, as you can see in the attached screenshot.  At this point it is counting all of them without factorying the date that I have filtered in the first column of this table.  Ultimately this group of dates (months) can/will change as the user uses the slider bar.

 

Early = CALCULATE(COUNTA('vw_PBI-OnTimeDelivery'[OTD_Status]),FILTER(ALL('vw_PBI-OnTimeDelivery'),'vw_PBI-OnTimeDelivery'[OTD_Status]="Early"))

Capture2.JPG

 

 

You want to create your calculations as measures rather than columns.  The binning that you appeared to do manually(?) can be accomplished with a date table (use the CALENDAR function).

 

Can you provide some of the raw data that you are working with? 

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.