Forum Discussion

Gemstar's avatar
Gemstar
Regular Visitor
4 years ago
Solved

Performance creation measure

Hello Everyone,

I'm very sorry to post here, but i looked for the answer everywhere and didn't find my solution,
I'm used to devellop a lot in python and VBA but i can't do a sinlge line of code in Power BI

I'm trying to add a new Measure a year to date performance in a variable text, but i'm struggling creating the measure.

this is my code

Mesure = divide(CALCULATE(sum('Histo Indices MASI'[INDICE MASI]),'Histo Indices MASI'[Date] = today() ),CALCULATE(sum('Histo Indices MASI'[INDICE MASI]),'Histo Indices MASI'[Date] = 12/31/2021))-1
 
Of course it doesn't work,

Is it possible to create a measure that will adapt to  any fields that i pick ?

Thanks again for your time

Regards

Gemstar
  • Hi, Gemstar ;

    You could try it.

    Mesure =
    DIVIDE (
        CALCULATE (
            SUM ( 'Histo Indices MASI'[INDICE MASI] ),
            'Histo Indices MASI'[Date] = TODAY ()
        ),
        CALCULATE (
            SUM ( 'Histo Indices MASI'[INDICE MASI] ),
            'Histo Indices MASI'[Date] = DATE ( 2021, 12, 31 )
        )
    ) - 1
    

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community
    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Look into the Quick Measures templates. They cover Year to Date scenarios as well.

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, Gemstar ;

    You could try it.

    Mesure =
    DIVIDE (
        CALCULATE (
            SUM ( 'Histo Indices MASI'[INDICE MASI] ),
            'Histo Indices MASI'[Date] = TODAY ()
        ),
        CALCULATE (
            SUM ( 'Histo Indices MASI'[INDICE MASI] ),
            'Histo Indices MASI'[Date] = DATE ( 2021, 12, 31 )
        )
    ) - 1
    

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community
    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Gemstar's avatar
      Gemstar
      Regular Visitor

      Hello  v-yalanwu-msft

       

      Thanks for your reply, i'll try that and come back to you

      if it's not working i'll upload a simplified ppbix with no sensitive data.

      thanks again.

      Have a nice day
       
      Gemstar