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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum values for each Distinct value

Hi, 

 

I'm trying to create a measure that returns the total number of weeks that are missing per person since the last date of their data upload, and then to sum all into a total value.

 

For example: 

 image.png

 

I created the following measure: 

 

Missing Weeks from last Update = CALCULATE(DISTINCTCOUNT(Calendar[Fiscal Week]), DATESBETWEEN(Calendar[Fiscal Week],LASTDATE('Table1'[Date])+1, TODAY())) * DISTINCTCOUNT('Table1'[Person ID])

 

That does the job well when it consider every case separately, for example on the left table presented above, it tells me how many weeks are missing per person, thats what I need and I want to sum all those missing weeks. But when it is summarized, obviously it just takes the last date of the table and returns 3. I would like for the measure to return the complete number, which in that example, would be 17, instead of 3. 

 

Please help on how  I could do this. 

 

Thanks

1 ACCEPTED SOLUTION

hi  @Anonymous 

This is a measure totals problem. Very common. See this post about it
https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

For your case, you need create a new measure like below:

m_Total 1 = 
VAR __table = SUMMARIZE('Table1',[Resource Name],"__value",[Missing Weeks from last Update])
RETURN
SUMX(__table,[__value])

Mow use this new measure in the visual.

 

 

Regards,

Lin

Community Support Team _ Lin
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

7 REPLIES 7
pranit828
Community Champion
Community Champion

HI @Anonymous 

try

CALCULATE(SUM(DATEDIFF(Today(), 'Table1'[Date], WEEK )),ALLXCEPT('table','Table'[Person ID]))





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Hi @Anonymous 

Can you please provide more info with screenshots, input and required output in table format for the community so that your ask can be better understood and resolved quickly.

 

From what I understand unless I see the input data.

CALCULATE(SUMX(DATEDIFF(Today(),calander[date], WEEK )-[diff in calander week and fiscal week]),ALLXCEPT('table','Table'[Person ID]))





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Anonymous
Not applicable

Sure @pranit828 , I'll try to explain my self better. 

 

I've got a table with records from users who upload records every week. What I need to know is, how many weeks are missing on the data in total since the last update per user. 

 

image.png

 

 Another example, my measure knows the number of missing weeks per person. But I need the sum of all those missing weeks. 

 

LuisGuzman98_3-1598643235787.png

Here's my current measure, i need for it to know the last date on the data of each person, calculate how many weeks are missing per each, and finally summing all of those. 

 

Missing Weeks from last Update = CALCULATE(DISTINCTCOUNT(Calendar[Fiscal Week]), DATESBETWEEN(Calendar[Fiscal Week],LASTDATE('Table1'[Actual Date]), TODAY())) * DISTINCTCOUNT('Table1'[Person ID])

 

Please tell me if you got any questions. 

Hi @Anonymous 

This issue seems like the column data type issue.

Make sure it is set to whole number.

pranit828_1-1598647813130.png

and the calulateion for that column is set to sum, in your case I believe it is set to max.

pranit828_3-1598647950807.png

 

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Anonymous
Not applicable

Hi @pranit828  I believe it's something more. 

 

I have it formatted as whole number

LuisGuzman98_1-1598651380321.png

 

And that option of SUM isn't available.

LuisGuzman98_0-1598651352392.png

 

Despite, I use the table for explanation. What I really need is for the complete number of missing weeks to appear in a card. 

Like this:

 

LuisGuzman98_3-1598651686017.png

 

 

 

hi  @Anonymous 

This is a measure totals problem. Very common. See this post about it
https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

For your case, you need create a new measure like below:

m_Total 1 = 
VAR __table = SUMMARIZE('Table1',[Resource Name],"__value",[Missing Weeks from last Update])
RETURN
SUMX(__table,[__value])

Mow use this new measure in the visual.

 

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @pranit828 , 

 

Thanks for your reply, but that didn't work. Also I dont want the normal calendar week, I want my fiscal year week which has already being calculated on the Calendar Table. 

 
The formula return the error: The SUM function only accepts a column reference as an argument.

 

Regards,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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