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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
selpaqm
Helper V
Helper V

Use EARLIER with if

Hi,

 

i have a table like below.  

IDName1Name2Totalshippedtrue/falseOrdertype
8AX1000300TRUEW
15AX 1200FALSEC
7CX 500TRUEX
16KX 300TRUEW
10CY300100TRUEQ
11DY 200TRUEW
17FY 400TRUEQ

first i need to find weight average for name2 related shipped (as weight)  and total (value which is will be seperated for empty cells.

Total Cost based total = DIVIDE(CALCULATE(SUM(Sheet1[Total]),FILTER(Sheet1,Sheet1[Name2]=EARLIER(Sheet1[Name2])))*Sheet1[shipped],CALCULATE(SUM(Sheet1[shipped]),FILTER(Sheet1,Sheet1[Name2]=EARLIER(Sheet1[Name2]))))
this formula can fix my first part.
1st.jpg
however, i need to add if to this formula because if there is an false in true/false column related for name2 i want to ignore the total and all total cost section for same name2 need to be zero.
for above table, Total Cost based total column against X should be zero.
hope everything is clear.
1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

You could consider this approach:

 

Total Cost Based Total =
VAR adjcosttotal = (your current expression)
VAR Falserows =
CALCULATE (
COUNTROWS ( Sheet1 ),
ALL(Sheet1), Sheet1[Name]=EARLIER(Sheet1[Name]),
Sheet1[true/false] = FALSE ()
)
RETURN
IF ( Falserows > 0, 0, adjcosttotal )





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Microsoft Employee
Microsoft Employee

You could consider this approach:

 

Total Cost Based Total =
VAR adjcosttotal = (your current expression)
VAR Falserows =
CALCULATE (
COUNTROWS ( Sheet1 ),
ALL(Sheet1), Sheet1[Name]=EARLIER(Sheet1[Name]),
Sheet1[true/false] = FALSE ()
)
RETURN
IF ( Falserows > 0, 0, adjcosttotal )





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


works fine,

thanks @mahoneypat 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors