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.
Dear all,
I have a table that I want to calculate sameperiodlastyear value, but since there are multi sameperiods in time column, the dax returns blank. My formula is like: Value_sameperiodlastyear = CALCULATE(sum[value],SAMEPERIODLASTYEAR([monthyear])).
My table example is as following:
monthyear | customer | Value | Value_sameperiodlastyear |
1/1/2017 | A | 1111 | 111 |
1/1/2017 | B | 2222 | 222 |
1/1/2017 | C | 3333 | 333 |
1/1/2016 | A | 111 | |
1/1/2016 | B | 222 | |
1/1/2016 | C | 333 |
Column "Value_sameperiodlastyear" is the result I want, by using the first three columns.
Do you guys know how to write the correct formula? Many thanks!
Solved! Go to Solution.
If you use the same formula as a MEASURE it will work
Probably you are using it as Calculated Column
= CALCULATE(sum(TableName[Value]),SAMEPERIODLASTYEAR(TableName[monthyear]))
If you have to use a Calculated Column use this
Column = CALCULATE ( SUM ( TableName[Value] ), ALLEXCEPT ( TableName, TableName[customer] ), SAMEPERIODLASTYEAR ( TableName[monthyear] ) )
If you use the same formula as a MEASURE it will work
Probably you are using it as Calculated Column
= CALCULATE(sum(TableName[Value]),SAMEPERIODLASTYEAR(TableName[monthyear]))
If you have to use a Calculated Column use this
Column = CALCULATE ( SUM ( TableName[Value] ), ALLEXCEPT ( TableName, TableName[customer] ), SAMEPERIODLASTYEAR ( TableName[monthyear] ) )
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 |
---|---|
107 | |
97 | |
75 | |
63 | |
53 |
User | Count |
---|---|
139 | |
100 | |
95 | |
85 | |
63 |