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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

ISBLANK in IF

Hi,

 

I have a measure (""Real_Orders" - connected with Database, future dates do not have a value) and a column ("Target_Orders" for each date in the next 6 months) and I want to subtract them, but only if "Real_Orders" are not empty. If there are no orders tracked (future dates), the subtraction should be 0.

 

I tried it like this:

IF(ISBLANK([Real_Orders]);0;([Real_Orders]-SUM(Target_Orders)))

 

Unfortunately it doesn't work and it seems that he is not replacing the subtraction with 0.

 

Thanks in advance.

Micha

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@v-jiascu-msft

 

Thank you for your help.

I solved it now a different way. I just filtered all future dates an subtract real orders with target orders.

 

View solution in original post

10 REPLIES 10
dedelman_clng
Community Champion
Community Champion

Depending on how your [Real Orders] measure is created, you may need to test on [Real Orders]=0 instead of BLANK().

 

Hope this helps.

David

Anonymous
Not applicable

Unfortunately not. It's the same.

The measure (real_orders) is based on DISTINCTCOUNT.

can you share your measure code and data model?

Anonymous
Not applicable

Hi,

I'm not sure what information you need (I'm new working with Power BI).

 

Measure: "Real_Orders"=DISTINCTCOUNT(Database[ID])

> Every unique ID is an order, if a customer selected more than one product, the ID is the same.

 

Data Model: Do you mean, which data/tables are given and their relations?

 

Database: As said: "Real_targets" results from these data

Date: master excel file (date, week, month, year, etc.) - relation between Database and Date via date (dd:mm:yyyy)

Target: excel file (target_orders, date) - relation between Target and Date via date (dd:mm:yyyy)

 

I hope that helps understanding.

 

@Anonymous

 

Hi,

 

DISTINCTCOUNT counts Blank as a unique value. So DISTINCTCOUNT always return value bigger or equal to 1. You can try this formula. 

Measure =

IF ( ISBLANK ( Database[ID] ), 0, [Real_Orders] - SUM ( [Target_Orders] ) )

 

 

Best Regards!

Dale Cui

 

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.
Anonymous
Not applicable

@v-jiascu-msft

 

Thank you. 

 

Database(ID) is no measure so I tried:

IF ( ISBLANK(DISTINCTCOUNT( Database[ID] ), 0, [Real_Orders] - SUM ( [Target_Orders] ) )

 

Still no change - still no 0 for every date with no value.

@Anonymous

 

Hi,

 

It's embarrassing. Database[ID] can't be used directly in there. ISBLANK(DISTINCTCOUNT( Database[ID] )) will never be BLANK. That is why there are no 0s. Maybe this would work. Please have a try.

Measure =
IF (
    COUNTBLANK ( Database[ID] ) > 0,
    0,
    [Real_Orders] - SUM ( [Target_Orders] )
)

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.
Anonymous
Not applicable

@v-jiascu-msft

 

Hi,

no change, unfortunately.

Maybe my measure "Real_Orders" is not that good to be based on DISTINCTCOUNT?! But I think there has to be a solution with those given circumstances...

 

Best Micha

 

@Anonymous

 

Hi,

 

"no change" means there is still no "0"s? The latest formula does nothing with Real_orders. Could you post a sample or share the PBIX file please?

 

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.
Anonymous
Not applicable

@v-jiascu-msft

 

Thank you for your help.

I solved it now a different way. I just filtered all future dates an subtract real orders with target orders.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.