Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Need help with the calculated measure?

Hello,    I have a table as shown below; The code for the measure is correct except the highlighted Values Logic: For report = Gross Profit in % of Sales and Header_1 <>Curr.to OEC, Sales...
  • v-lili6-msft's avatar
    7 years ago

    hi, Anonymous

    After my research on your sample pbix file, you could this formula

    New Value2 = 
    IF (
        VALUES ( POC[report_param] ) = "Gross Profit in % of Sales" && VALUES ( POC[Header_2] ) <> "Curr.to OEC",
            (
                (
                    CALCULATE (
                        [Value Measure],
                        FILTER ( ALL ( POC ), POC[report_param] = "Gross Profit" ),
                        VALUES ( POC[Country] ),
                        VALUES ( POC[Snapshot Date] ),
                        VALUES ( POC[Header_1] ),
                        VALUES ( POC[Header_2] ),
                        VALUES ( POC[project_number] )
                    )
                        / (
                            CALCULATE (
                                [Value Measure],
                                FILTER ( ALL ( POC ), POC[report_param] = "Sales" ),
                                VALUES ( POC[Country] ),
                                VALUES ( POC[Snapshot Date] ),
                                VALUES ( POC[Header_1] ),
                                VALUES ( POC[Header_2] ),
                                VALUES ( POC[project_number] )
                            )
                        )
                )
            ),
    
        IF (
            VALUES ( POC[report_param] ) = "Gross Profit in % of Sales"
                && VALUES ( POC[Header_2] ) = "Curr.to OEC",
                (
                    (
                        CALCULATE (
                            [Value Measure],
                            FILTER (
                                ALLEXCEPT(POC,POC[project_number]),
                                POC[Header_2] = "Curr.mth."
                                    && POC[report_param] = "Gross Profit"
                            ),
                            VALUES ( POC[Country] ),
                            VALUES ( POC[Snapshot Date] ),
                            --VALUES ( POC[Header_1] ),
                            --VALUES ( POC[Header_2] ),
                            VALUES ( POC[project_number] )
                        )
                            / CALCULATE (
                                [Value Measure],
                                FILTER (
                                    ALLEXCEPT(POC,POC[project_number]),
                                    POC[Header_2] = "Curr.mth."
                                        && POC[report_param] = "Sales"
                                ),
                                VALUES ( POC[Country] ),
                                VALUES ( POC[Snapshot Date] ),
                                --VALUES ( POC[Header_1] ),
                                --VALUES ( POC[Header_2] ),
                                VALUES ( POC[project_number] )
                            )
                    )
                        - (
                            CALCULATE (
                                [Value Measure],
                                FILTER (
                                    ALLEXCEPT(POC,POC[project_number]),
                                    POC[Header_2] = "Upd.OEC"
                                        && POC[report_param] = "Gross Profit"
                                ),
                                VALUES ( POC[Country] ),
                                VALUES ( POC[Snapshot Date] ),
                                VALUES ( POC[Region] ),
                                --VALUES ( POC[Header_1] ),
                                --VALUES ( POC[Header_2] ),
                                VALUES ( POC[project_number] )
                            )
                                / CALCULATE (
                                    [Value Measure],
                                    FILTER ( ALLEXCEPT(POC,POC[project_number]), POC[Header_2] = "Upd.OEC" && POC[report_param] = "Sales" ),
                                    VALUES ( POC[Country] ),
                                    VALUES ( POC[Snapshot Date] ),
                                    --VALUES ( POC[Header_1] ),
                                    --VALUES ( POC[Header_2] ),
                                    VALUES ( POC[project_number] )
                                )
                        )
                ),
           [Value Measure]
        )
    )
    

    First, Header_1 only has three values (Budget, Forecast, Actuals ), so VALUES ( POC[Header_1] ) <> "Curr.to OEC" is wrong in your formula.

     

    second, be careful for For report = Gross Profit in % of Sales and Header_2 = Curr.to OEC conditional.

    FILTER (
    ALL ( POC ),
    POC[Header_1] = "Curr.mth."
    && POC[report_param] = "Gross Profit"
    ),
    VALUES ( POC[Country] ),
    VALUES ( POC[Snapshot Date] ),
    --VALUES ( POC[Header_1] ),
    VALUES ( POC[Header_2] ),
    VALUES ( POC[project_number] )
    )

     

    FILTER (
    ALL ( POC ),
    POC[Header_1] = "Curr.mth."
    && POC[report_param] = "Sales"
    ),
    VALUES ( POC[Country] ),
    VALUES ( POC[Snapshot Date] ),
    --VALUES ( POC[Header_1] ),
    VALUES ( POC[Header_2] ),
    VALUES ( POC[project_number] )
    )

     

    FILTER (
    ALL ( POC ),
    POC[Header_1] = "Upd.OEC"
    && POC[report_param] = "Gross Profit"
    ),
    VALUES ( POC[Country] ),
    VALUES ( POC[Snapshot Date] ),
    VALUES ( POC[Region] ),
    --VALUES ( POC[Header_1] ),
    VALUES ( POC[Header_2] ),
    VALUES ( POC[project_number] )

    )

     

    FILTER ( ALL ( POC ), POC[Header_1] = "Upd.OEC" && POC[report_param] = "Sales" ),
    VALUES ( POC[Country] ),
    VALUES ( POC[Snapshot Date] ),
    --VALUES ( POC[Header_1] ),
    VALUES ( POC[Header_2] ),
    VALUES ( POC[project_number] )
    )

     

    in my formula.

     

    Result:

     

     

    Best Regards,

    Lin