cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
NirH_at_BITeam Frequent Visitor
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 v-qiuyu-msft
Moderator

Re: DAX - Better way to write a formula

Hi @NirH_at_BITeam

 

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.
NirH_at_BITeam Frequent Visitor
Frequent Visitor

Re: DAX - Better way to write a formula

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

 

NH

Helpful resources

Announcements
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

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

Top Ideas
Users Online
Currently online: 27 members 894 guests
Please welcome our newest community members: