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

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

Reply
Anonymous
Not applicable

DAX - IF Format

Hi All,

 

I am trying to do a SUM on column [Total Amount] when column [Promotion_id] is blank AND column [order_order_scr] = 1

 

My DAX for new column is;

 

NoOfferTotal = IF(AND(FORMAT([order_order_src] = 1,"String"), 'POS Data 1'[promotion_id] = " "),SUM('POS Data 1'[Total Amount]),0)

 

This errors and DAX comparison operations do not support values of string and integer. 

 

Any help would be appreicated.

1 ACCEPTED SOLUTION

@v-jiascu-msft is right and it's a better solution in case that promition_id is actually "" in some cases.

 

revised codes:

measure = 
CALCULATE(
	SUM('POS Data 1'[Total Amount]),
	'POS Data 1'[promotion_id] = BLANK(),
	'POS Data 1'[order_order_src] = 1 
)

column =
IF( 
    AND( 
        'POS Data 1'[promotion_id] = BLANK(),
        'POS Data 1'[order_order_src] = 1
    ),
	'POS Data 1'[Total Amount]
)
/sdjensen

View solution in original post

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

@Anonymous

 

Hi,

 

It seems that the answer is there. So I just give a suggestion that you can replace "" with BLANK(). "Format" isn't  needed.

 

 

Best Regards!

Dale

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

@v-jiascu-msft is right and it's a better solution in case that promition_id is actually "" in some cases.

 

revised codes:

measure = 
CALCULATE(
	SUM('POS Data 1'[Total Amount]),
	'POS Data 1'[promotion_id] = BLANK(),
	'POS Data 1'[order_order_src] = 1 
)

column =
IF( 
    AND( 
        'POS Data 1'[promotion_id] = BLANK(),
        'POS Data 1'[order_order_src] = 1
    ),
	'POS Data 1'[Total Amount]
)
/sdjensen
sdjensen
Solution Sage
Solution Sage

Hi @Anonymous,

 

You can calculate this as a measure with this DAX code. I would however prefer to make the calculation a measure instead of a column unless you for some reason really need this as a column in your table.

 

NoOfferTotal = 
CALCULATE(
	SUM('POS Data 1'[Total Amount]),
	FORMAT( 'POS Data 1'[promotion_id], "String" ) = "",
	'POS Data 1'[order_order_src] = 1 
)

 

If you really need it as a column - this code should do the trick:

IF( 
    AND( 
        FORMAT( 'POS Data 1'[promotion_id]; "String" ) = "",
        'POS Data 1'[order_order_src] = 1
    ),
	'POS Data 1'[Total Amount]
)

 

 

/sdjensen
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

Can you please show a snapshot of some of the data so we can see what kind of values are in each column?

 

That will help reformat the query.

 

I'm mostly interested in the [order_order_src] column


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

Thanks for the replies.

 

Both column are whole numbers, see screen shots.

 

order src.PNGpromotion id.PNG

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors