Forum Discussion
Comparing values in same colums by year and categorie
- 2 years ago
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Thnx!
Can you explain the second part of the code, so I get a better understanding?
-
You define a variable
__AAA, which calculates the percentage ([% pr]) for the category "AAA" in your table. TheCALCULATEfunction applies filters to the data, usingALLEXCEPTto preserve filtering on the 'Table'[Code] and 'Table'[F Year] columns and adding an additional filter where 'Table'[Code] equals "AAA." -
Then you have a
RETURNstatement, which returns a result based on a condition. In this condition, it checks if the maximum code ('Table'[Code]) is equal to "AAA." If it is, it returns 0 (presumably to prevent division by zero). If the code is not "AAA," it goes into the nested condition. -
Inside the nested condition, it checks whether the value of
__AAAis less than your percentage[% pr]. If__AAAis less than[% pr], it returns 1; otherwise, it returns 0. This is likely used to determine whether the percentage for the "AAA" category exceeds a specified threshold.
Overall, this code appears to be part of a larger data model or data query, and its precise meaning depends on the context and the goals of your analysis.