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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
matrix_user
Helper III
Helper III

Grouping of minutes in calculated column.

Hi all,

 

I am trying to group time results/values from a calculated column (Call Duration Difference) into another calculated column (LoT).

 

The grouping of time is from seconds to hours (0 -4 mins, 5 - 9 mins...90+ mins). 

 

The DAX I have written in the LoT column is not accepting how I want to group time except for the last criteria, “0 – 4” but for all rows:

 

matrix_user_2-1646953139250.png

 

matrix_user_0-1646952772574.jpeg

 

Am I missing a Filter function of some sort given that the 0 – 4 is on all rows. I know that green text (90, 75, 60 etc) is not what I expected. What DAX can I use to fix this? I aim to use the groups in both visual axis and visual filter.

 

Some background info:

 

  • The Call Duration Difference column are results from an arithmetic calculation (StartTime minus EndTime) these values are in Date/time data type.
  • The Call Duration Difference column is in Time data type.
  • The LoT column is in Text data type.

 

Any help is much appreciated.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Finally sent through! Try using TIME(0,1,30) instead of 90 and etc.

View solution in original post

v-eqin-msft
Community Support
Community Support

Hi @matrix_user ,

 

According to my understanding, you want to create a flag column based on time duration(seconds), right?

 

If so, you could use [Call Duration Difference]*60*60*24 to firstly get total seconds( same for minutes —— * 60*24)

then try SWITCH() instead of nested if.

 

For example:

LoT =
VAR _second = [Call Duration Difference] * 60 * 60 * 24
RETURN
    SWITCH (
        TRUE (),
        _second >= 90, "90+",
        _second >= 80, "80-89",
        _second >= 60, "60-79",
        _second >= 40, "40-59",
        _second >= 20, "20-39",
        _second >= 5, "5-19",
        "0-4"
    )

Output:

Eyelyn9_0-1647331836356.png

 

Best Regards,
Eyelyn Qin
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

7 REPLIES 7
v-eqin-msft
Community Support
Community Support

Hi @matrix_user ,

 

According to my understanding, you want to create a flag column based on time duration(seconds), right?

 

If so, you could use [Call Duration Difference]*60*60*24 to firstly get total seconds( same for minutes —— * 60*24)

then try SWITCH() instead of nested if.

 

For example:

LoT =
VAR _second = [Call Duration Difference] * 60 * 60 * 24
RETURN
    SWITCH (
        TRUE (),
        _second >= 90, "90+",
        _second >= 80, "80-89",
        _second >= 60, "60-79",
        _second >= 40, "40-59",
        _second >= 20, "20-39",
        _second >= 5, "5-19",
        "0-4"
    )

Output:

Eyelyn9_0-1647331836356.png

 

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

matrix_user
Helper III
Helper III

Hi... can anyone help please?

Anonymous
Not applicable

Not sure why my replies keep disappearing...

 

YongChen_0-1646957786097.png

 

Anonymous
Not applicable

Finally sent through! Try using TIME(0,1,30) instead of 90 and etc.

I tried replicating your suggestion but nothing (blue cover is "Table 1") :

matrix_user_1-1646983043716.png

The red lines shows minutes over 4 mins but still grouped into the "0 - 4" LoT.

matrix_user_2-1646983162867.png

 

Anonymous
Not applicable

What data type does your Call Duration uses, mine is Time with hh:nn:ss Format, is it possible to change it?

Hi YongChen, mine is the same.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.