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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bmarcowka
Helper I
Helper I

The Goal is Zero (or thataboy)

I am wanting to have the result of blank be Zero or Text (haven't decided).  I have (actually my peer) tried numerous attempts at using a combination of the IF(ISBLANK) and IS(BLANK) to no avail.  Hoping I can get some assistance and/or placement of syntax

 

Current Syntax: 

Most Recent Serv Charge =

VAR CustNoMaxDate =

CALCULATE(MAX(OrgStops[ServiceDate]), FILTER(OrgStops, EARLIER(OrgStops[CustNo])=OrgStops[CustNo] && (OrgStops[ServiceCharge]>0 || OrgStops[MonthlyCharge]>0)))

VAR PerServiceCharge =

CALCULATE(LASTNONBLANK(OrgStops[ServiceCharge],1) , FILTER(OrgStops, OrgStops[ServiceDate]=CustNoMaxDate && EARLIER(OrgStops[CustNo])=OrgStops[CustNo] && OrgStops[ServiceCharge]>0))



VAR MonthlyServiceCharge =

CALCULATE(LASTNONBLANK(OrgStops[MonthlyCharge],1) , FILTER(OrgStops, OrgStops[ServiceDate]=CustNoMaxDate && EARLIER(OrgStops[CustNo])=OrgStops[CustNo] && OrgStops[MonthlyCharge]>0))/4

VAR MRServCharge =
SWITCH(TRUE(),
MonthlyServiceCharge=0, PerServiceCharge, MonthlyServiceCharge)

RETURN

MRServCharge
 
Goal of Zero.JPG

 

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @bmarcowka ,

 

Referring to your formula, there seems to be no logical problem.
I think you can determine the correctness of the formula by returning each reference created in turn.


If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.

How to Get Your Question Answered Quickly - Microsoft Power BI Community


Best Regards,
Henry


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

MFelix
Super User
Super User

Hi @bmarcowka ,

 

Try to wrap the last part into a coalesce something similar to:

 

Most Recent Serv Charge =
VAR CustNoMaxDate =
    CALCULATE (
        MAX ( OrgStops[ServiceDate] ),
        FILTER (
            OrgStops,
            EARLIER ( OrgStops[CustNo] ) = OrgStops[CustNo]
                && ( OrgStops[ServiceCharge] > 0
                || OrgStops[MonthlyCharge] > 0 )
        )
    )
VAR PerServiceCharge =
    CALCULATE (
        LASTNONBLANK ( OrgStops[ServiceCharge], 1 ),
        FILTER (
            OrgStops,
            OrgStops[ServiceDate] = CustNoMaxDate
                && EARLIER ( OrgStops[CustNo] ) = OrgStops[CustNo]
                && OrgStops[ServiceCharge] > 0
        )
    )
VAR MonthlyServiceCharge =
    CALCULATE (
        LASTNONBLANK ( OrgStops[MonthlyCharge], 1 ),
        FILTER (
            OrgStops,
            OrgStops[ServiceDate] = CustNoMaxDate
                && EARLIER ( OrgStops[CustNo] ) = OrgStops[CustNo]
                && OrgStops[MonthlyCharge] > 0
        )
    ) / 4
VAR MRServCharge =
    SWITCH (
        TRUE (),
        MonthlyServiceCharge = 0, PerServiceCharge,
        MonthlyServiceCharge
    )
RETURN
    COALESCE ( MRServCharge, 0 )

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix  No go.  Resolves without error but same result. 

Hi @bmarcowka 

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.