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
Chewbaklava
Frequent Visitor

Help me Understand why my Total column isn't working

unnamed.png

Below is the measure and above is the values table (contracts x Fiscal Year x Cost per FY)

unnamed.png


My values are all correct -- giving me the $$ that each contract will pay during the relavent FYs.


However, the Total column is very wrong. Appears to be giving me conCost / numDays. I would love some support to understand why this is happening and how to fix it.

(Filter FY Range returns 1 for each FY during the Contract date range. Returns blank otherwise)

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Chewbaklava 

@SELECTEDVALUE returns blank at the total level for most of (if not all) the variables. Even if you change to MAX or MIN the result at the total level will allways be wrong.

please try

Cost per FY =
SUMX (
    VALUES ( FY[Fiscal Year] ),
    CALCULATE (
        VAR constart =
            SELECTEDVALUE ( contracts[Start] )
        VAR conEd =
            SELECTEDVALUE ( contracts[End] )
        VAR conCost =
            SELECTEDVALUE ( contracts[Total Cost] )
        VAR numDays =
            DATEDIFF ( conStart, conEnd, DAY ) + 1
        VAR daysinfy =
            DATEDIFF (
                MAX ( conStart, CALCULATE ( SELECTEDVALUE ( FY[FY Start] ) ) ),
                MIN (
                    COALESCE ( conEnd, CALCULATE ( SELECTEDVALUE ( FY[FY end] ) ) ),
                    CALCULATE ( SELECTEDVALUE ( FY[FY end] ) )
                ),
                DAY
            ) + 1
        RETURN
            IF ( [Filter Fy Range], daysinfy * conCost / numDays, BLANK () )
    )
)

 

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Chewbaklava 

@SELECTEDVALUE returns blank at the total level for most of (if not all) the variables. Even if you change to MAX or MIN the result at the total level will allways be wrong.

please try

Cost per FY =
SUMX (
    VALUES ( FY[Fiscal Year] ),
    CALCULATE (
        VAR constart =
            SELECTEDVALUE ( contracts[Start] )
        VAR conEd =
            SELECTEDVALUE ( contracts[End] )
        VAR conCost =
            SELECTEDVALUE ( contracts[Total Cost] )
        VAR numDays =
            DATEDIFF ( conStart, conEnd, DAY ) + 1
        VAR daysinfy =
            DATEDIFF (
                MAX ( conStart, CALCULATE ( SELECTEDVALUE ( FY[FY Start] ) ) ),
                MIN (
                    COALESCE ( conEnd, CALCULATE ( SELECTEDVALUE ( FY[FY end] ) ) ),
                    CALCULATE ( SELECTEDVALUE ( FY[FY end] ) )
                ),
                DAY
            ) + 1
        RETURN
            IF ( [Filter Fy Range], daysinfy * conCost / numDays, BLANK () )
    )
)

 

Brilliant, Tysm!

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.