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
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
Community Champion
Community Champion

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
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!

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.