Forum Discussion

Khalidshurafa's avatar
Khalidshurafa
Frequent Visitor
2 years ago
Solved

Need DAX Measure Correction

Dears, I need help with correcting the below DAX measure in which I target measuing progress from latest available date in the data report as it includes data from several dates please note that ...
  • Khalidshurafa's avatar
    Khalidshurafa
    2 years ago

    Hi Anonymous 
    I actually was able to fix it myself after deep analysis of the measure,

     

    I actually had one reference inside the varibel called LatestDate to another table in the data model which wasnt supposed to be there,

     

    Below is the correct one,

     

    Overall Actual Progress =
     VAR LatestDate = CALCULATE(MAX('Weekly Progress'[Reporitng Date]), ALL('Weekly Progress'[Reporitng Date]))
     VAR SingleBuildingProgress = SELECTEDVALUE(SubAssets[BuildingName])
     VAR EntireAssetProgress = SELECTEDVALUE(SubAssets[Asset Name])
     VAR SelectedAssetBUA = SELECTEDVALUE('Weekly Progress'[Building BUA])
     VAR TotalBUAForAsset = CALCULATE(SUM('Weekly Progress'[Building BUA]), SubAssets[Asset Name] = EntireAssetProgress, 'Weekly Progress'[Reporitng Date] = LatestDate)
     
     RETURN
     IF(
        ISBLANK(EntireAssetProgress),
        SUMX(
            FILTER('Weekly Progress', 'Weekly Progress'[Reporitng Date] = LatestDate),
            'Weekly Progress'[Actual Progress] * 'Weekly Progress'[Building BUA] / SUMX(
                FILTER('Weekly Progress', 'Weekly Progress'[Reporitng Date] = LatestDate),
                'Weekly Progress'[Building BUA]
            )
        ),
        IF(
            NOT(ISBLANK(SingleBuildingProgress)),
            LOOKUPVALUE(
                'Weekly Progress'[Actual Progress],
                'Weekly Progress'[BuildingName], SingleBuildingProgress, 'Weekly Progress'[Reporitng Date], LatestDate
            ),
            CALCULATE(
                SUMX(
                    FILTER('Weekly Progress', 'Weekly Progress'[Reporitng Date] = LatestDate),
                    'Weekly Progress'[Building BUA] * 'Weekly Progress'[Actual Progress] * DIVIDE(
                        1,
                        TotalBUAForAsset
                    )
                ),
                SubAssets[Asset Name] = EntireAssetProgress
            )
        )
    )
     
    Thanks mate,