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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

average dax

Hello to all,

I would like to make weekly and monthly averages of train punctuality in percentage.

Excel does it very well (screen view in pj) but I think it should be possible to do it in power bi desktop.

Every weekend I want power bi to divide the total number of non-punctual trains by the total number of trains to feed a percentage gauge.

I have tried different DAX formulas and measurements but I can't get it right. Would you have a formula to do this calculation?

image.png

 

thank you

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Thank you for your posting, and I want to share how I proceed.

 

1. create custom-date table -> assign as a date table

2. create a relationship with Data table

3. Write the below three measures to calculate the percentage.

4. please check the picture if it is what you are looking for.

please also check the link down below, that is the sample pbix file

 

Ponctuels weekly total =
VAR allweek =
FILTER (
ALL ( dates ),
dates[ISO Weeknumber] = SELECTEDVALUE ( dates[ISO Weeknumber] )
)
VAR allweektotal =
CALCULATE ( SUM ( Data[Ponctuels] ), allweek )
RETURN
IF ( SELECTEDVALUE ( dates[DayOfWeek] ) = 0, allweektotal, BLANK () )
 
Trains weekly total =
VAR allweek =
FILTER (
ALL ( dates ),
dates[ISO Weeknumber] = SELECTEDVALUE ( dates[ISO Weeknumber] )
)
VAR allweektotal =
CALCULATE ( SUM ( Data[Trains] ), allweek )
RETURN
IF ( SELECTEDVALUE ( dates[DayOfWeek] ) = 0, allweektotal, BLANK () )
 
Ponctuels by Trains =
DIVIDE( [Ponctuels weekly total], [Trains weekly total], BLANK())
 
Picture2.png
 
 
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Thank you for your posting, and I want to share how I proceed.

 

1. create custom-date table -> assign as a date table

2. create a relationship with Data table

3. Write the below three measures to calculate the percentage.

4. please check the picture if it is what you are looking for.

please also check the link down below, that is the sample pbix file

 

Ponctuels weekly total =
VAR allweek =
FILTER (
ALL ( dates ),
dates[ISO Weeknumber] = SELECTEDVALUE ( dates[ISO Weeknumber] )
)
VAR allweektotal =
CALCULATE ( SUM ( Data[Ponctuels] ), allweek )
RETURN
IF ( SELECTEDVALUE ( dates[DayOfWeek] ) = 0, allweektotal, BLANK () )
 
Trains weekly total =
VAR allweek =
FILTER (
ALL ( dates ),
dates[ISO Weeknumber] = SELECTEDVALUE ( dates[ISO Weeknumber] )
)
VAR allweektotal =
CALCULATE ( SUM ( Data[Trains] ), allweek )
RETURN
IF ( SELECTEDVALUE ( dates[DayOfWeek] ) = 0, allweektotal, BLANK () )
 
Ponctuels by Trains =
DIVIDE( [Ponctuels weekly total], [Trains weekly total], BLANK())
 
Picture2.png
 
 
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Pragati11
Super User
Super User

Hi @Anonymous ,

 

You can use a DAX something like below: 

If you want to create a column then use below and chnage the datatype to percentage:

calc = DIVIDE([Total number of non punctual trains], [Total number of trains], 0)

 

If you want to create a measure, then use the following:

calc = DIVIDE(SUM([Total number of non punctual trains]), SUM([Total number of trains]), 0)

 

Just use your original columns and tablename in the above dax calculations.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.