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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
manoj_0911
Helper IV
Helper IV

Issues with DurationFormatted in Power BI Visuals

Hi everyone,

I'm encountering some challenges while working with a calculated column named `ACW DurationFormatted` (converts seconds to HH:MM:SS) in Power BI visuals.

**Card Visual Issue:**

1. **Problem:** When I drag `ACW DurationFormatted` to a card visual, it only displays "00:00:00."
2. **Current Selection:** The fields selection in the card visual is set to "First" by default.

**Question:**

* What am I missing here? How can I display the sum or average of the `ACW DurationFormatted` values in the card visual?
* How should the calculation change for sum or average aggregation within the card visual?

**Line Chart Issue:**

1. **Problem:** When I drag `ACW DurationFormatted` to the X-axis of a line chart and `Weekday` to the Y-axis, the visualization changes `Weekday` to "Count of Weekday."
2. **Desired Outcome:** I want to see the trend of average or sum of `ACW DurationFormatted` by weekday.

**Question:**

* How can I fix this and display the desired trend with weekday on the X-axis and average/sum of `ACW DurationFormatted` on the Y-axis?

**Additional Information:**

* `ACW DurationFormatted` is a calculated column using formulas to convert seconds to HH:MM:SS format.

manoj_0911_0-1712220518515.png

 

manoj_0911_1-1712220525654.png

 

ACW Hours = INT([ACW_DURATION] / 3600)
ACW Minutes = INT(MOD([ACW_DURATION], 3600) / 60)
ACW Seconds = MOD([ACW_DURATION], 60)

ACW DurationFormatted =
FORMAT([ACW Hours], "00") & ":" &
FORMAT([ACW Minutes], "00") & ":" &
FORMAT([ACW Seconds], "00")


------------------------------------------

Weekday = FORMAT([IXN_SUBHOUR_DATE],"DDD")

Thanks in advance for your assistance!

Manoj Prabhakar

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@manoj_0911 This is because you are ending up with a duration that is text. You need to use custom format strings like this: Chelsie Eiden's Duration - Microsoft Fabric Community


Follow on LinkedIn
@ 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...

View solution in original post

v-jianpeng-msft
Community Support
Community Support

Thanks @Greg_Deckler 

Hi, @manoj_0911 

Have you solved the current problem now? I tested your DAX expression and your question using the sample data below:

vjianpengmsft_0-1713420087078.png

First I created the following calculated columns using the DAX you provided, and since creating the calculated columns here would have a circular dependency, I added ALLEXCEPT('Table (2)', 'Table (2)'[seconds]) to each DAX:

vjianpengmsft_1-1713420239549.png

vjianpengmsft_2-1713420252529.png

vjianpengmsft_3-1713420277179.png

vjianpengmsft_4-1713420292068.png

vjianpengmsft_5-1713420321788.png

In my tests, the card visual was indeed able to show the first value, indicating that there is no problem with your DAX, as shown in the following image:

vjianpengmsft_6-1713420430993.png

For the following two problems, I use the following DAX expression to sum and average:

How can I display the sum or average of the `ACW DurationFormatted` values in the card visual?
How should the calculation change for sum or average aggregation within the card visual?

Average ACW DurationFormatted1 =
VAR _totalsecond =
    CALCULATE ( SUM ( 'Table (2)'[seconds] ), ALL ( 'Table (2)' ) )
VAR _hours =
    INT ( DIVIDE ( _totalsecond / 3600, DISTINCTCOUNT ( 'Table (2)'[seconds] ) ) )
VAR _Minutes =
    INT (
        DIVIDE (
            MOD ( _totalsecond, 3600 ) / 60,
            DISTINCTCOUNT ( 'Table (2)'[seconds] )
        )
    )
VAR _second =
    INT (
        DIVIDE ( MOD ( _totalsecond, 60 ), DISTINCTCOUNT ( 'Table (2)'[seconds] ) )
    )
RETURN
    _hours & ":" & _Minutes & ":" & _second
Sum ACW DurationFormatted =
VAR _totalsecond =
    CALCULATE ( SUM ( 'Table (2)'[seconds] ), ALL ( 'Table (2)' ) )
VAR _hours =
    INT ( _totalsecond / 3600 )
VAR _Minutes =
    INT ( MOD ( _totalsecond, 3600 ) / 60 )
VAR _second =
    MOD ( _totalsecond, 60 )
RETURN
    _hours & ":" & _Minutes & ":" & _second

Both DAX expressions are used to create measures. The idea of calculating the average value is to add all the seconds and then average the Hour, minutes, and seconds respectively. The idea of summing is to first find the total number of seconds, and then calculate the hours, minutes, and seconds corresponding to this total number of seconds. 

Here are the results:

vjianpengmsft_7-1713421154562.png

 

How can I fix this and display the desired trend with weekday on the X-axis and average/sum of `ACW DurationFormatted` on the Y-axis?

For the above problem, since ACW DurationFormatted is a Text type data, it cannot be put into the Y axis.

vjianpengmsft_8-1713421275767.png

If you place this one calculated column in the Y-axis, it will only count that column, not show the composite or average.

vjianpengmsft_9-1713421449709.png

The main reason for this is that ACW DurationFormatted is not a value, but a text. I've provided the PBIX file used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

2 REPLIES 2
v-jianpeng-msft
Community Support
Community Support

Thanks @Greg_Deckler 

Hi, @manoj_0911 

Have you solved the current problem now? I tested your DAX expression and your question using the sample data below:

vjianpengmsft_0-1713420087078.png

First I created the following calculated columns using the DAX you provided, and since creating the calculated columns here would have a circular dependency, I added ALLEXCEPT('Table (2)', 'Table (2)'[seconds]) to each DAX:

vjianpengmsft_1-1713420239549.png

vjianpengmsft_2-1713420252529.png

vjianpengmsft_3-1713420277179.png

vjianpengmsft_4-1713420292068.png

vjianpengmsft_5-1713420321788.png

In my tests, the card visual was indeed able to show the first value, indicating that there is no problem with your DAX, as shown in the following image:

vjianpengmsft_6-1713420430993.png

For the following two problems, I use the following DAX expression to sum and average:

How can I display the sum or average of the `ACW DurationFormatted` values in the card visual?
How should the calculation change for sum or average aggregation within the card visual?

Average ACW DurationFormatted1 =
VAR _totalsecond =
    CALCULATE ( SUM ( 'Table (2)'[seconds] ), ALL ( 'Table (2)' ) )
VAR _hours =
    INT ( DIVIDE ( _totalsecond / 3600, DISTINCTCOUNT ( 'Table (2)'[seconds] ) ) )
VAR _Minutes =
    INT (
        DIVIDE (
            MOD ( _totalsecond, 3600 ) / 60,
            DISTINCTCOUNT ( 'Table (2)'[seconds] )
        )
    )
VAR _second =
    INT (
        DIVIDE ( MOD ( _totalsecond, 60 ), DISTINCTCOUNT ( 'Table (2)'[seconds] ) )
    )
RETURN
    _hours & ":" & _Minutes & ":" & _second
Sum ACW DurationFormatted =
VAR _totalsecond =
    CALCULATE ( SUM ( 'Table (2)'[seconds] ), ALL ( 'Table (2)' ) )
VAR _hours =
    INT ( _totalsecond / 3600 )
VAR _Minutes =
    INT ( MOD ( _totalsecond, 3600 ) / 60 )
VAR _second =
    MOD ( _totalsecond, 60 )
RETURN
    _hours & ":" & _Minutes & ":" & _second

Both DAX expressions are used to create measures. The idea of calculating the average value is to add all the seconds and then average the Hour, minutes, and seconds respectively. The idea of summing is to first find the total number of seconds, and then calculate the hours, minutes, and seconds corresponding to this total number of seconds. 

Here are the results:

vjianpengmsft_7-1713421154562.png

 

How can I fix this and display the desired trend with weekday on the X-axis and average/sum of `ACW DurationFormatted` on the Y-axis?

For the above problem, since ACW DurationFormatted is a Text type data, it cannot be put into the Y axis.

vjianpengmsft_8-1713421275767.png

If you place this one calculated column in the Y-axis, it will only count that column, not show the composite or average.

vjianpengmsft_9-1713421449709.png

The main reason for this is that ACW DurationFormatted is not a value, but a text. I've provided the PBIX file used this time below.

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Greg_Deckler
Super User
Super User

@manoj_0911 This is because you are ending up with a duration that is text. You need to use custom format strings like this: Chelsie Eiden's Duration - Microsoft Fabric Community


Follow on LinkedIn
@ 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...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.