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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
kbauro97
New Member

Sum formula with condition by level

Hi, 

I've been trying to make this work but I haven't found the answer.

 

I have 3 levels: Zone, Component and person. For example, this is the data:

ZoneComponentPersonWork hrs
Zone 1Component 1Simon1.5
Zone 1Component 1Peter-1
Zone 1Component 1Simon2
Zone 1Component 2Simon4
Zone 1Component 2Peter-2
Zone 1Component 2Simon-7
Zone 1Component 2Simon-4
Zone 1Component 2Peter1

I want to create a formula where I would sum only the negative values from the person's sum to obtain the component's sum. The positives values will turn 0.


I would like to create a table where I can get the column "Data": 

kbauro97_1-1646271043671.png

Here you can see the column "Normal sum", It sums positives and negatives to obtain the component sum.

I want to obtain the data column, where the positive values from the person will turn to 0 (such as the 3.5 from Simon), so that I can only sum the negative hrs and obtain the -9 value.

 

Which formula could I use?
I hope you can help me to solve this issue. Thank you.

 

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

Hi @kbauro97 ,

 

Check the formulas.

measure = CALCULATE(SUM(TableA[Work hrs]),ALLEXCEPT(TableA,TableA[Zone],TableA[Component],TableA[Person]))
Measure 2 = IF([measure]>0,0,[measure])
Measure 3 = SUMX(TableA,[Measure 2]/CALCULATE(COUNT(TableA[Person]),ALLEXCEPT(TableA,TableA[Zone],TableA[Component],TableA[Person])))
Result:
1.jpg
 
Best Regards,
Jay
Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @kbauro97 ,

 

Check the formulas.

measure = CALCULATE(SUM(TableA[Work hrs]),ALLEXCEPT(TableA,TableA[Zone],TableA[Component],TableA[Person]))
Measure 2 = IF([measure]>0,0,[measure])
Measure 3 = SUMX(TableA,[Measure 2]/CALCULATE(COUNT(TableA[Person]),ALLEXCEPT(TableA,TableA[Zone],TableA[Component],TableA[Person])))
Result:
1.jpg
 
Best Regards,
Jay
Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@kbauro97 ,

Create a measure first

normal sum = sum(Table[Value])

 

Then

sumx(filter(values(Table[Person]), [Normal sum] >0 ), [Normal Sum])

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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