Forum Discussion

third_hicana's avatar
third_hicana
Icon for Helper IV rankHelper IV
4 years ago
Solved

DAX for Remaining Percent Left and Reflect in Bar Graph

Hi Power BI Experts. I would like to ask your help please for my bar chart in the bottom.   I want to to reflect in the bottom bar chart the remaining percent left. As you can see in the upper bar ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi third_hicana  ,

    Please pay attention to the  position of the parentheses.

    Measure =
    VAR _mindate =
        MINX ( ALLSELECTED ( Sheet1 ), Sheet1[month] )
    VAR _vapacityvalue =
        CALCULATE (
            MAX ( Sheet1[Capacity Assigned] ),
            FILTER ( ALL ( Sheet1 ), Sheet1[month] = _mindate )
        )
    VAR _project =
        CALCULATE (
            MAX ( Sheet1[project] ),
            FILTER ( ALL ( Sheet1 ), Sheet1[month] = _mindate )
        )
    VAR _1result =
        IF (
            MAX ( Sheet1[project] ) = _project,
            MAX ( Sheet1[Maximum Percent] ) - MAX ( Sheet1[Capacity Assigned] ),
            IF (
                MAX ( Sheet1[project] ) <> _project,
                MAX ( Sheet1[Maximum Percent] ) - MAX ( Sheet1[Capacity Assigned] ) - _vapacityvalue,
                BLANK ()
            )
        )
    VAR _before =
        CALCULATE (
            MAX ( Sheet1[end date] ),
            FILTER ( ALL ( Sheet1 ), Sheet1[rankx] = SELECTEDVALUE ( Sheet1[rankx] ) - 1 )
        )
    VAR _year =
        YEAR ( _before )
    VAR _month =
        MONTH ( _before )
    VAR _timebigthan =
        IF (
            MAX ( Sheet1[year] ) = _year
                && MAX ( Sheet1[month_column] ) >= _month,
            1,
            0
        )
    RETURN
        IF (
            MAX ( Sheet1[_countproject] ) <> 1
                && MAX ( Sheet1[rankx] ) = 1,
            _1result,
            IF (
                MAX ( Sheet1[_countproject] ) <> 1
                    && MAX ( Sheet1[rankx] ) <> 1
                    && _timebigthan = 1,
                MAX ( Sheet1[Maximum Percent] ) - MAX ( Sheet1[Capacity Assigned] ),
                _1result
            )
        )

     

    Best Regards

    Community Support Team _ Polly

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.