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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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