Forum Discussion

rasika_pawar's avatar
rasika_pawar
Frequent Visitor
1 year ago
Solved

Need help in DAX

We are creating a measure where we are calculating one logic which is 

Win of Benchmark + Organic of Benchmark - Organic of Survey

where,

Benchmark is last year date 

Survey is current year date

Win is the contracts which are created in that year

Organic is the contracts which are available in the last year and renewed in the current year

How the formula will calculate is suppose we are having 2 years which are 2023(survey) and 2022(benchmark)

Win of Benchmark means contracts which are created in 2022 and Organic of Benchmark means contracts which are available in 2021 and renewed in 2022.

Organic of Survey means contracts which are available in 2022 and renewed in 2023.

So, it will sum Win of Benchmark and Organic of Benchmark and then subtract it from Organic of Survey. But it should work when we select date from survey Period slicer and benchmark period slicer at the same time. it should work for same period last year and any date from last year for e.x. survey period is Jul 2023 and benchmark period is Dec 2022.

  • Hey there! 

     

    So if I understood, you want a DAX measure that calculates Win of Benchmark + Organic of Benchmark - Organic of Survey, while ensuring it works with the Survey Period and Benchmark Period slicers. 

    Maybe try thisone: 

    Win_Organic_Calculation =
    VAR SurveyYear = SELECTEDVALUE(SurveyTable[Year]) -- Get selected Survey Year
    VAR BenchmarkYear = SurveyYear - 1 -- Benchmark Year is Survey Year - 1

    -- Win of Benchmark: Contracts created in Benchmark Year
    VAR Win_Benchmark =
    CALCULATE(
    COUNTROWS(ContractsTable),
    ContractsTable[CreationYear] = BenchmarkYear
    )

    -- Organic of Benchmark: Contracts active in Benchmark Year that were renewed from two years ago
    VAR Organic_Benchmark =
    CALCULATE(
    COUNTROWS(ContractsTable),
    ContractsTable[StartYear] = BenchmarkYear - 1,
    ContractsTable[RenewalYear] = BenchmarkYear
    )

    -- Organic of Survey: Contracts active in Survey Year that were renewed from Benchmark Year
    VAR Organic_Survey =
    CALCULATE(
    COUNTROWS(ContractsTable),
    ContractsTable[StartYear] = BenchmarkYear,
    ContractsTable[RenewalYear] = SurveyYear
    )

    -- Final Calculation
    RETURN Win_Benchmark + Organic_Benchmark - Organic_Survey

     

    This will hopefully do everything you want. 

     

    Cheerio,

    Z๐Ÿ˜๐Ÿ˜

5 Replies

  • freginier's avatar
    freginier
    Solution Sage

    Hey there! 

     

    So if I understood, you want a DAX measure that calculates Win of Benchmark + Organic of Benchmark - Organic of Survey, while ensuring it works with the Survey Period and Benchmark Period slicers. 

    Maybe try thisone: 

    Win_Organic_Calculation =
    VAR SurveyYear = SELECTEDVALUE(SurveyTable[Year]) -- Get selected Survey Year
    VAR BenchmarkYear = SurveyYear - 1 -- Benchmark Year is Survey Year - 1

    -- Win of Benchmark: Contracts created in Benchmark Year
    VAR Win_Benchmark =
    CALCULATE(
    COUNTROWS(ContractsTable),
    ContractsTable[CreationYear] = BenchmarkYear
    )

    -- Organic of Benchmark: Contracts active in Benchmark Year that were renewed from two years ago
    VAR Organic_Benchmark =
    CALCULATE(
    COUNTROWS(ContractsTable),
    ContractsTable[StartYear] = BenchmarkYear - 1,
    ContractsTable[RenewalYear] = BenchmarkYear
    )

    -- Organic of Survey: Contracts active in Survey Year that were renewed from Benchmark Year
    VAR Organic_Survey =
    CALCULATE(
    COUNTROWS(ContractsTable),
    ContractsTable[StartYear] = BenchmarkYear,
    ContractsTable[RenewalYear] = SurveyYear
    )

    -- Final Calculation
    RETURN Win_Benchmark + Organic_Benchmark - Organic_Survey

     

    This will hopefully do everything you want. 

     

    Cheerio,

    Z๐Ÿ˜๐Ÿ˜

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi rasika_pawar,

    Thanks for reaching out to the Microsoft fabric community forum.

    It looks like you are looking for a way to write a measure to do some arithmetic operations on the your data. As freginier already responded to your query, can you please go through the response provided and check if it solves your issue.

     

    I would also take a moment to thank freginier, for actively participating in the community forum and for the solutions youโ€™ve been sharing in the community forum. Your contributions make a real difference.

     

    If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

    Best Regards,
    Hammad.
    Community Support Team

     

    If this post helps then please mark it as a solution, so that other members find it more quickly.

    Thank you.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi rasika_pawar,

      As we havenโ€™t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.

      If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.


      If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
      Thank you for your patience and look forward to hearing from you.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi rasika_pawar,

        I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.


        Thank you.