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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SebastianS86
Frequent Visitor

Sum some categories for the same date

dear all,

 

Please help me to solve a problem. I'm a beginner and I need to solve a problem. I attached a sampe data. I want to group all the fruits belonging to a certain date. The reason is tha I need to add in a graph, per day, the following cat.:

- fruits (apple + orange+ banana)

- PC

- car

- House 

 

can you please help me?

Screenshot 2024-02-22 155221.png

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

Hi @SebastianS86 

 

@amitchandak  GOOD ANSWER!

 

Here are my additions:

 

You can create a calculated column.

Type1 = SWITCH(TRUE(),
[Type] = "apple" || [Type] = "bannana" || [Type] = "orange", "fruits",
[Type] = "Bicycle", "Car",
[Type] = "house", "House",
[Type] = "PC", "PC")

 

And a measure.

Sum = CALCULATE(SUM('Table'[Cost]), ALLEXCEPT('Table', 'Table'[Type1], 'Table'[Date])) 

 

Or do the following:

vxuxinyimsft_0-1708660296322.png

 

Output:

vxuxinyimsft_1-1708660328775.png

 

vxuxinyimsft_2-1708660349090.png

Is this the result you expect?

 

Best Regards,
Yulia Xu

 

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

4 REPLIES 4
SebastianS86
Frequent Visitor

It seems to work. Thank you all.

It was also usefull the exemple!

SebastianS86
Frequent Visitor

Thank you Both. I will start to test it but it seems logical. I will come back if something is not clear for me.

v-xuxinyi-msft
Community Support
Community Support

Hi @SebastianS86 

 

@amitchandak  GOOD ANSWER!

 

Here are my additions:

 

You can create a calculated column.

Type1 = SWITCH(TRUE(),
[Type] = "apple" || [Type] = "bannana" || [Type] = "orange", "fruits",
[Type] = "Bicycle", "Car",
[Type] = "house", "House",
[Type] = "PC", "PC")

 

And a measure.

Sum = CALCULATE(SUM('Table'[Cost]), ALLEXCEPT('Table', 'Table'[Type1], 'Table'[Date])) 

 

Or do the following:

vxuxinyimsft_0-1708660296322.png

 

Output:

vxuxinyimsft_1-1708660328775.png

 

vxuxinyimsft_2-1708660349090.png

Is this the result you expect?

 

Best Regards,
Yulia Xu

 

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

amitchandak
Super User
Super User

@SebastianS86 , You need to create a calculated column using Switch

 

Switch(True() ,

[Type] in {"apple","orange","banana"} , "fruits",

//add additional code

"Others"

)

 

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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