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
Dunner2020
Post Prodigy
Post Prodigy

sum up measure with some conditions

Hi there,

 

I have data that records the date and time of the event that happened in the past and the value of the event. I have categorized the events into half-hour blocks (using time intelligence ). The idea is the value of events that occurred in the same half-hour block should be summed up. My data looks as follow:

 

leo_89_0-1612484803056.png

 

As you can see above three events occurred on 6/26/2019 between 9:30 am to 10:00 am in the same half-hour block i.e. 9:30 am. I created a measure [30 mins value] that sum up the events that occurred in the same half-hour block. Now I want to calculate the sum of the measure [30 mins value]. I used the following measure to calculate the sum of all event values:

All_sumup_30 = SUMX(Table1, [30 mins value]).

 

The problem with the above formula is that it adds up 0.00425 three times (as it appears 3 times). Is there any way of summing up where I could say if the same date has the same half-hour block more than once then consider only one times? For example, 0.00425 add with other values only once, not three times. 

 

Sample file can be download from here

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Dunner2020 try this measure and test it

 

Sum 30 Min = 
SUMX ( SUMMARIZE ( Table1, Table1[Date], 'Time'[Half Hour], "@30min", [30 mins value] ), [@30min] ) 

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@Dunner2020 try this measure and test it

 

Sum 30 Min = 
SUMX ( SUMMARIZE ( Table1, Table1[Date], 'Time'[Half Hour], "@30min", [30 mins value] ), [@30min] ) 

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Dunner2020  I have no idea which table is what? You should always post a question with sample data and the model to understand define the problem, with partial information it is very hard to figure out the solution, and also it can save lot of back and forth.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I have included the sample file.

parry2k
Super User
Super User

@Dunner2020 I guess these tables have the relation? and how they are related? one to many, many to many? if one to many which table is one side?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Yes, there is a relation exists. The time table has one to many relations with the fact table. I also have got date table which also has one to many relations with the fact table

parry2k
Super User
Super User

@Dunner2020 you should add another column and extract the date from your date/time column and then add the following measure:

 

New Measure =
SUMX ( 
SUMMARIZE ( Table, Table[Date Only Column], Table[Half Hour Block], "@30MinValue", MAX ( Table[30 Mins Value] ),
[@30MinValue]
)

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

What if Half hour column comes from the other table? In my case, it is coming from the time table. 

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.