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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register 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
Anonymous
Not applicable

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
Anonymous
Not applicable

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.

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

 

 

Anonymous
Not applicable

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
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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