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
nicoenz
Helper III
Helper III

Conditional sum in DAX

Hi ,

i have the the following table:

ProductFiscal yearSum of QTY
Product A20210
Product A2022550
Product B20212947
Product B20222195
Product C20211000
Product C20220
Product E202190
Product E20220
Product F20221800
Product G20210
Product G20220

 

I would like to know how much business we won and how much we lost in 2022. To do this the formulae will be:

Business won:
if( "volume of product 2021" = 0 and "volume of product 2022" > 0 return the sum of QTY for 2021)

Product A and F meet this condition => Business Won = 550 + 1180 = 1730

 

Business lost:
if( "volume of product 2022" = 0 and "volume of product 2021" > 0 return the sum of QTY for 2021)

Product C and E meet this condition => Business lost = 1000 + 90 = 1090

 

I tried many different options but can't solve it. I'd really appreciate a hand in this!!

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1667560423599.png

 

For fun only, a showcase of powerful Excel worksheet formula,

CNENFRNL_1-1667560513418.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
nicoenz
Helper III
Helper III

Hi BeaBF,

With volume i meant "Sum of QTY". apologies for not being so clear.

ProductFiscal year         Sum of QTY
Product A         20210
Product A2022550
Product B20212947
Product B20222195
Product C20211000
Product C20220
Product E202190
Product E20220
Product F20221800
Product G20210
Product G20220

Business won: I want a measure that will go through all the rows and check the QTY column. If in 2021 the QTY was 0 (or no value) and in 2022 QTY>0, then this means that it is business won for that product. I want to return the sum of all business won.

In the table, Product A has 0 in 2021 and 550 in 2022. Therefore it is business won of 550. Likewise, Product F's QTY is null for 2021 and 1800 for 2022. Therefore it is a business won of 1800

The total of business won is 2350. 

I want a measure that will calculate that number

same logic for the Business lost

 

 

CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1667560423599.png

 

For fun only, a showcase of powerful Excel worksheet formula,

CNENFRNL_1-1667560513418.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Hi CNENFRNL,
my table also contains data for other years which i would like to ignore. how can i filter them out?
Your DAX includes the data from those "unwanted" years
 
 
 
 

exactly what i needed!!! thanks

BeaBF
Super User
Super User

@nicoenz  Hi!

What do you mean with "volume of product 2021" and "volume of product 2022"? Can you better explain the expected result, with a table maybe?

 

BBF

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.