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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
michalnrf
Frequent Visitor

Dax measure circular dependecy

Hello,
I'm trying to create two measures Available and End.  For first I'm taking start value and then add parameter A and substract parameter B equals End. Next week for Available I'm taking End value for previous week. Every time when I'm trying prepare measure to calculate this I'm receiving circular dependecy problem. Can you give me some advice or show some solution how can I solve my problem? (manual example below)

Thank you in advance.

michalnrf_0-1706180319131.png

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @michalnrf,

You can try to use following measure formula if it suitable for your requirement:

Available =
VAR _initValue =
    CALCULATE (
        MIN ( Table1[StartValue] ),
        FILTER ( ALLSELECTED ( Table1 ), [StartValue] <> BLANK () )
    )
VAR currYW =
    MAX ( Table1[Year Week] )
VAR rollingA =
    CALCULATE (
        SUM ( Table1[ParameterA] ),
        FILTER ( ALLSELECTED ( Table1 ), [Year Week] < currYW )
    )
VAR rollingB =
    CALCULATE (
        SUM ( Table1[ParameterB] ),
        FILTER ( ALLSELECTED ( Table1 ), [Year Week] < currYW )
    )
RETURN
    _initValue - rollingA + rollingB
    
End =
VAR _initValue =
    CALCULATE (
        MIN ( Table1[StartValue] ),
        FILTER ( ALLSELECTED ( Table1 ), [StartValue] <> BLANK () )
    )
VAR currYW =
    MAX ( Table1[Year Week] )
VAR rollingA =
    CALCULATE (
        SUM ( Table1[ParameterA] ),
        FILTER ( ALLSELECTED ( Table1 ), [Year Week] <= currYW )
    )
VAR rollingB =
    CALCULATE (
        SUM ( Table1[ParameterB] ),
        FILTER ( ALLSELECTED ( Table1 ), [Year Week] <= currYW )
    )
RETURN
    _initValue - rollingA + rollingB

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @michalnrf,

You can try to use following measure formula if it suitable for your requirement:

Available =
VAR _initValue =
    CALCULATE (
        MIN ( Table1[StartValue] ),
        FILTER ( ALLSELECTED ( Table1 ), [StartValue] <> BLANK () )
    )
VAR currYW =
    MAX ( Table1[Year Week] )
VAR rollingA =
    CALCULATE (
        SUM ( Table1[ParameterA] ),
        FILTER ( ALLSELECTED ( Table1 ), [Year Week] < currYW )
    )
VAR rollingB =
    CALCULATE (
        SUM ( Table1[ParameterB] ),
        FILTER ( ALLSELECTED ( Table1 ), [Year Week] < currYW )
    )
RETURN
    _initValue - rollingA + rollingB
    
End =
VAR _initValue =
    CALCULATE (
        MIN ( Table1[StartValue] ),
        FILTER ( ALLSELECTED ( Table1 ), [StartValue] <> BLANK () )
    )
VAR currYW =
    MAX ( Table1[Year Week] )
VAR rollingA =
    CALCULATE (
        SUM ( Table1[ParameterA] ),
        FILTER ( ALLSELECTED ( Table1 ), [Year Week] <= currYW )
    )
VAR rollingB =
    CALCULATE (
        SUM ( Table1[ParameterB] ),
        FILTER ( ALLSELECTED ( Table1 ), [Year Week] <= currYW )
    )
RETURN
    _initValue - rollingA + rollingB

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
lbendlin
Super User
Super User

You should be able to cover this specific scenario with SUMX.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.