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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Patrick-K
Regular Visitor

SumX with distinct value of a combination: Yearly view is broken, but monthly view is ok

Dear experts,

 

unfortunately I am struggling with a problem, I have used the following link as a guide:

 

https://community.fabric.microsoft.com/t5/Desktop/Dax-for-sum-of-distinct-values/td-p/1446048

 

I have a large dataset that is structured in the following way:

 

Work centerPlantYearPeriod&YearMachine time (h)Working DaysCode
1110202201.202210201105
1110202201.20225201205
2110202201.202215201105
3110202201.202220201205
4150202201.202240201105
5150202201.202250201200
6150202201.202260201105
all110202101.202140021all
all1110202102.202150019all

 

Table excerpt for 2022 with working days since this is my main issue:

 

Work centerPlantYearPeriod&YearMachine time (h)Working DaysCode
all110202201.2022400.00021all
all110202202.2022405.00020all
all110202203.2022

 

395.000

23all
all110202204.2022375.00019all
all110202205.2022360.00021all
all110202206.2022450.00020all
all110202207.2022450.00021all
all110202208.2022440.00023all
all110202209.2022430.00022all
all110202210.2022420.00022all
all110202211.2022410.00021all
all110202212.2022400.00021all
Total1102022all4.935.000252all

 

The dataset is growing each month and includes data from 2016 onwards in this structure. There is no hierarchy for year & year.period for drilldown, but since the data is maintained in the rows as listed above I am not expecting an issue.

 

I want to achive the following: Calcuate the number of shifts per plant, per each work center & also considering the codes.

But this is also my issue since it's essentially counting the working times x times (due to several codes per work center per period). 

 

My DAX formula:

SUMX TEST V3 =
SUMX(SUMMARIZE(Table','Period.Year,'Plant),MAX([Working days]))

 

My issue:

When I insert my measure on the level of Period.Year for each plant, it returns the correct number per period. There is 1 column per period, so 12 in total with the correct values each = sum 252

When I insert my measure on the level of Year however, it somehow returns a total of 276. I have been looking for the issue for 3 hours now and just can't find it.. The delta is also 24, which doesn't exist as a working day entry in my dataset for 2022...

 

Thanks for your help, I hope my description is clear enough.

 

 

 

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Patrick-K ,

 

Please try:

SUMX TEST V3 = 
SUMX(SUMMARIZE('Table','Table'[Period&Year],'Table'[Plant],"Value",MAX('Table'[Working Days])),[Value])

Final output:

vjianbolimsft_0-1689301211215.png

Best Regards,

Jianbo Li

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

1 REPLY 1
v-jianboli-msft
Community Support
Community Support

Hi @Patrick-K ,

 

Please try:

SUMX TEST V3 = 
SUMX(SUMMARIZE('Table','Table'[Period&Year],'Table'[Plant],"Value",MAX('Table'[Working Days])),[Value])

Final output:

vjianbolimsft_0-1689301211215.png

Best Regards,

Jianbo Li

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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