cancel
Showing results 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

Helper V

## DAX Needed - SUM of Days, but Not for Non-Unique Values

I have the following data which has 17 different workorders but only 5 different system description class 1/downtime start/downtime end combinations. They each have a Downtime Day of 1.

I have numerous other rows that are have downtime days for the same class 1 and are unique values.

How do I write DAX to sum downtime days for all unique rows, but for the values that are not unique only take the datediff between downtime start and downtime end once?

So for the above, if I rollup to ALARM only, it would show Downtime Days = 5? It currently shows 17 since it is summing each row.

1 ACCEPTED SOLUTION
Community Support

Hi @KMcCarthy9 ,

Based on my testing, please try the following methods again:

1.Create the simple table.

2.Create the new column to combine.

Unique combine =
CONCATENATE(
CONCATENATE([System Description Class 1], CONCATENATE("_", [Downtime Start])),
CONCATENATE("-", [Downtime End])
)

3.Create the new measure to calculate the days.

Unique days =
SUMX(
VALUES('Table'[Unique combine]),
CALCULATE(
MAX('Table'[Downtime Days]),
ALLEXCEPT('Table', 'Table'[Unique combine])
)
)

4.Drag the measure into the table visual. The result is shown below.

Best Regards,

Wisdom Wu

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

3 REPLIES 3
Community Support

Hi @KMcCarthy9 ,

Based on my testing, please try the following methods:

1.Create the simple table.

2.Create the new column to combine.

Downtime Combinations =
CONCATENATE(
CONCATENATE([System Description Class 1], CONCATENATE("_", [Downtime Start])),
CONCATENATE("-", [Downtime End])
)

3.Create the new measure to calculate the days.

Unique Downtime Days = SUMX(DISTINCT('Table'[Downtime Combinations]), 1)

4.Drag the measure into the card visual. The result is shown below.

Solved: Dax for sum of distinct values - Microsoft Fabric Community

Solved: Sum of values based on distinct values in other co... - Microsoft Fabric Community

Best Regards,

Wisdom Wu

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

Helper V

@v-jiewu-msft Thank you for your answer, but this doesn't quite get what I need.

This is giving me the distinct count of the class/downtime rows, however this would only work if the downtime days = 1. What about rows that the downtime days = 2, 3, 4, etc? If each example above was 2 days, I would need the final Downtime Days = 10.

Also, I am looking for 1 DAX solution that will sum the dwntime days for all unique combinations, but only sum the non-unique combinations once.

For example, if there is 1 row under ALARM that reads CLEANER, downtime from 1/8/24 - 1/11/24, I would want the results to show:
ALARM = 5
CLEANER = 3

I will check out the links you provided.

Community Support

Hi @KMcCarthy9 ,

Based on my testing, please try the following methods again:

1.Create the simple table.

2.Create the new column to combine.

Unique combine =
CONCATENATE(
CONCATENATE([System Description Class 1], CONCATENATE("_", [Downtime Start])),
CONCATENATE("-", [Downtime End])
)

3.Create the new measure to calculate the days.

Unique days =
SUMX(
VALUES('Table'[Unique combine]),
CALCULATE(
MAX('Table'[Downtime Days]),
ALLEXCEPT('Table', 'Table'[Unique combine])
)
)

4.Drag the measure into the table visual. The result is shown below.

Best Regards,

Wisdom Wu

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

Announcements

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

#### Power BI Monthly Update - August 2024

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

#### Microsoft Fabric & AI Learning Hackathon

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

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors