Forum Discussion

th3h0bb5's avatar
th3h0bb5
Resolver II
9 years ago
Solved

Aggregating Custom formatted numbers

Is there a way to aggregate a column that has a custom numerical format? For instance, let's say I want to display some leading zeros:   Formatted = FORMAT([Sales],"000000") Now a Sales value of 1...
  • dkay84_PowerBI's avatar
    dkay84_PowerBI
    9 years ago

    First, I was able to take your Time Per Patient and create the duration field more easily.  Simply add a custom column that takes [Time Per Patient]/86400.  (86400 is seconds per day).  Then, convert the data type to "Duration"

     

    You can have charts that display duration info in aggregated form, such as a line or bar chart (provided you have an appropriate X axis for your line chart, such that each row of your patient time has a month or day of week or whatever).  However, the display of the value will be in decimal form, and thus is not very useful for you if you wish to see values in hh:mm:ss format.

     

    See posts on this board: http://community.powerbi.com/t5/Desktop/Duration-as-Y-Axis/td-p/82651

     

    If you wish to create measures, you should be able to aggregate first then format the measure.  In other words, you would use DAX to create your measure (i.e. difference in average time this period vs last period) on the underlying data [Time Per Patient], and nest this function inside of a format function to have it return the result as you prefer.

     

    Example:

    Avg.Time = FORMAT(CALCULATE(AVERAGE(PatientTimes[FormattedTime]),ALL(PatientTimes)),"hh:mm:ss")

     

    The red code is your filter argument.  I don't have any fields to filter as I literally just copied the example data you provided.  However, if you have a field for month or day of week or whatever you want your measure to filter by, it would go in here in place of my red text.