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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
KBedor
Frequent Visitor

Total current month if prior month value = 0

Help!  I've been tried more suggestions from this community than I can count, including Greg Deckler's patterns, and still can't seem to get the correct total.  

 

My fact table has project budgets by Month and Year.  I've created measures for current and prior months, which work as expected regardless off the month selected in the slicer.  

 

Now the business wants to see current month values where Prior Month = 0 so I wrote this measure:

 

NoPriorAmount = VAR prior = [PriorMoEACRev]

VAR currmon = [CurrEACRev]

RETURN IF(prior=0,[CurrEACRev],0)

 

Of couse the total row value is 0.

The measure will need to be sliced by a location and business unit dimensions.  Any help would be greatly appreciated.  See below for a table with sample data from the fact table, followed by my measures. 

KBedor_0-1604696130953.png

 

PriorMonEAC = CALCULATE(SUM(Bookings[eacrv]),DATEADD('Calendar'[Date],-1,MONTH))

CurrEAC = SUM(Bookings[eacrv])

NoPriorAmount = VAR prior = [PriorMoEACRev]

VAR currmon = [CurrEACRev]

RETURN IF(prior=0,[CurrEACRev],0)

Total New Bkgs = Total New Bkgs = VAR __table = SUMMARIZE('Services Lines',"__value",[New Bookings])

RETURN

IF(HASONEVALUE('Services Lines'[Line of Service]),[New Bookings],SUMX(__table,[__value]))

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NoPriorAmount =
SUMX (
    VALUES ( Project[Project] ),
    VAR prior = [PriorMoEACRev]
    VAR currmon = [CurrEACRev]
    RETURN
        IF ( prior = 0, [CurrEACRev], 0 )
)

View solution in original post

3 REPLIES 3
wdx223_Daniel
Super User
Super User

NoPriorAmount =
SUMX (
    VALUES ( Project[Project] ),
    VAR prior = [PriorMoEACRev]
    VAR currmon = [CurrEACRev]
    RETURN
        IF ( prior = 0, [CurrEACRev], 0 )
)

Thank you!!  That works.  Performance is slow, but the result is accurate.   I'm marking this as the solution, although if anyone has recommendations to improve performance that would be helpful.

 

AlB
Super User
Super User

Hi @KBedor 

Can you share the pbix?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors