Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi
i need to create an expression in which i filter max year month, max year month-1 and max year month-12
sometrhing like this?
Solved! Go to Solution.
Hi @cosminc
If I understand correctly you need 3 months: MaxYM, MaxYM-1 and MaxYM-12, i.e. if MaxYM = 201901 you want 201901, 201812 and 201801. Correct? If not please provide a clearer example with numbers to illustrate what you're after. If correct, try this:
MTD = VAR _MaxYM = CALCULATE ( MAX ( Source[YM] ), ALL ( Source ) ) VAR _MaxYM_12 = _MaxYM - 100 VAR _MaxYM_1 = IF ( MOD ( _MaxYM, 100 ) = 1, _MaxYM - 100 + 11, _MaxYM - 1 ) VAR _Months = { _MaxYM, _MaxYM_1, _MaxYM_12 } RETURN CALCULATE ( SUM ( Source[Sales] ), Source[YM] IN _Months )
Hi @cosminc
If I understand correctly you need 3 months: MaxYM, MaxYM-1 and MaxYM-12, i.e. if MaxYM = 201901 you want 201901, 201812 and 201801. Correct? If not please provide a clearer example with numbers to illustrate what you're after. If correct, try this:
MTD = VAR _MaxYM = CALCULATE ( MAX ( Source[YM] ), ALL ( Source ) ) VAR _MaxYM_12 = _MaxYM - 100 VAR _MaxYM_1 = IF ( MOD ( _MaxYM, 100 ) = 1, _MaxYM - 100 + 11, _MaxYM - 1 ) VAR _Months = { _MaxYM, _MaxYM_1, _MaxYM_12 } RETURN CALCULATE ( SUM ( Source[Sales] ), Source[YM] IN _Months )
Perfect!
Thanks a lot!
Cosmin
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
110 | |
91 | |
84 | |
66 |