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
ambisset
Regular Visitor

Usage per day by periods

I'm new to Power BI so learning the syntax and capabilities of DAX is a work in progress. I've searched for what I'm trying to do but not finding a similar solution.

 

I work for a harbour and within the harbour we have a number of berths. I have successfully created from our raw data a table of berth usages. This has these relevant fields...

Date, BerthID, OccupiedPercentage (ie: percentage of day berth was occupied expressed as a decimal 0-1). eg:

01/01/2019, 1, .5

01/01/2019, 2, .75

02/01/2019, 1, .6

etc

 

I've got a table of dates with heirarchies that I've used before in other reports and that gives a drill down by year, quarter, month, week, day. That works.

 

When I link to the BerthUsage I'm getting the summed total of the daily percentages for that berth when what I need is the cumulative figure expressed as a percentage of the number of days that were selected.

 

An example may help 

If the user is viewing an entire year and is looking at berth 1 I want to see that the percentage utilisation for that berth for the year is the sum of the daily percentages/365 to give the occupancy percentage for that year. 

 

I am assuming I need to divide the sum of percentages by the number of days in the period block the user is looking at but I can't workout the correct syntax for the DAX measure.

 

Thanks in advance for your assistance.

1 ACCEPTED SOLUTION

I've ended up using a simple average function as a measure for now it appears to do a reasonable job although it's rather crude.

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Perhaps something along the lines of:

 

Measure = 
VAR __table = ALLSELECTED('Table')
RETURN
SUMX(__table,[OccupiedPercentage]) / COUNTROWS(__table)

@ 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...

Sadly that only seems to return the same value regardless of the date. I'm assuming that it should be a table level measure and not in a column?

 

Measure 1:= VAR __table = ALLSELECTED('Berth Usage') RETURN SUMX(__table,[BerthPercentage]) / COUNTROWS(__table)

 

Have I misinterpreted the formula?

image.png

If I add berths it just shows exactly the same value by berth as well. So it's as if that formula is only working on the whole table.

image.png

This is what the PowerBI visualisation trial looks like...

image.png

 

It's picking up the relationships from the SSDT relationship model as follows. This splits by date just fine if I just use the BerthPercentage field rather than the measure however it sums it rather than showing the average for that period.

image.png

I've ended up using a simple average function as a measure for now it appears to do a reasonable job although it's rather crude.

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.