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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.