cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## DAX - Better way to write a formula

Hi,

I use ISBLANK  a lot in one of my BI models and I wonder if there is a better and much more efficient way to write the below measure.

I have many other measures that check first if the result is zero and if not then it applies the formula itself.

Any help would be highly appreciated.

Thanks!

NH

Count Invoice Awaitng Approval OR Partially Approved =
IF (
ISBLANK (
CALCULATE (
COUNTX (
AllJobsData,
AllJobsData[Z02 Count Submitted Invc with NO ApprovedInvc OR Partial Approval]
),
FILTER (
AllJobsData,
AllJobsData[Z02 Count Submitted Invc with NO ApprovedInvc OR Partial Approval] = 1
)
)
),
0,
(
CALCULATE (
COUNTX (
AllJobsData,
AllJobsData[Z02 Count Submitted Invc with NO ApprovedInvc OR Partial Approval]
),
FILTER (
AllJobsData,
AllJobsData[Z02 Count Submitted Invc with NO ApprovedInvc OR Partial Approval] = 1
)
)
)
)
2 REPLIES 2
Moderator

## Re: DAX - Better way to write a formula

You can use Variable in the measure:

Count Invoice Awaitng Approval OR Partially Approved =
VAR t =
CALCULATE (
COUNTX (
AllJobsData,
AllJobsData[Z02 Count Submitted Invc with NO ApprovedInvc OR Partial Approval]
),
FILTER (
AllJobsData,
AllJobsData[Z02 Count Submitted Invc with NO ApprovedInvc OR Partial Approval] = 1
)
)
RETURN
IF ( ISBLANK ( t ), 0, t )

Best Regards,
Qiuyun Yu

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

## Re: DAX - Better way to write a formula

Not sure if this actually simplifies the formula but thanks anyway!

NH

Announcements

#### Back to School Contest

Engage and empower students with Power BI!

#### Watch Sessions On Demand!

Continue your learning in our online communities.

#### Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

#### PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 27 members 894 guests
Recent signins: