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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
KMcCarthy9
Helper V
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. 

KMcCarthy9_0-1716931691510.png

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

Hi @KMcCarthy9 ,

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

1.Create the simple table.

vjiewumsft_0-1717141873908.png

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.

vjiewumsft_1-1717141908044.png

 

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.

View solution in original post

3 REPLIES 3
v-jiewu-msft
Community Support
Community Support

Hi @KMcCarthy9 ,

Based on my testing, please try the following methods:

1.Create the simple table.

vjiewumsft_0-1716947908480.png

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.

vjiewumsft_1-1716947939842.png

You can also view the following link to learn more information.

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.

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

 

 

Hi @KMcCarthy9 ,

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

1.Create the simple table.

vjiewumsft_0-1717141873908.png

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.

vjiewumsft_1-1717141908044.png

 

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.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.