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

Top Kudoed Authors