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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

Top Solution Authors