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.
I am trying to write a measure that can be updated by parameter values. I had this working as a calculated table but I'm having trouble getting one of the measures to work. Essentially what I am trying to do is calculate the sum of a specific set of values in a running total. The set is defined by years (I need to go from the present year back 15 years in this case). Once I have that SUM I'm entering it into the PMT function.
This is the measure I'm trying to fix........
Sum of Annual Values for past 15 years =
VAR Rate = .0275
VAR Periods = 15
VAR PeriodSum =
SUMX (
CALCULATETABLE (
ADDCOLUMNS (
Years,
"Running Total", [RT]
),
Years[Year] <= SELECTEDVALUE ( Years[Year] ) &&
Years[Year] > SELECTEDVALUE ( Years[Year] ) - Periods
),
[Running Total]
)
RETURN
PMT ( Rate, Periods, - PeriodSum )
The above measure is placed in a visual, say a table, the first column is Years[Year], and then the measure would follow.
My Years table is this: Years = GENERATESERIES (2022 , 2022 + 50, 1 )
And the [RT] measure is a value that increments up each year.
When I run the measure I get the correct values for the first year, 2022, through 2037, and then (after 15years) it goes flat and returns the same value for the rest of the years. I'm guessing there's something wrong with my filter context of Years[Year] but I can't figure it out. If anyone can offer a suggestion, I will greatly appreciate it.
Graphically, this is what I'm trying t do:
Solved! Go to Solution.
Hi @UBComma ,
Due to I don't know your data model, I create a sample to have a test. I create a Year table by generateseries function.
[RT] in my sample:
RT =
VAR _START = 1
VAR _BEGIN_YEAR = 2022
RETURN
(MAX(Years[Year]) - _BEGIN_YEAR) * _START
Result is as below.
In my side, [Sum of Annual Values for past 15 years] measure works well. I think your problem my be casued by [RT] , measure. You can try to add ALL, ALLSELECTED or ALLEXCEPT function in your measure. Or you can share a sample file with me and show me a screenshot with the result you want. This will make it easier for me to find the solution.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @UBComma ,
Due to I don't know your data model, I create a sample to have a test. I create a Year table by generateseries function.
[RT] in my sample:
RT =
VAR _START = 1
VAR _BEGIN_YEAR = 2022
RETURN
(MAX(Years[Year]) - _BEGIN_YEAR) * _START
Result is as below.
In my side, [Sum of Annual Values for past 15 years] measure works well. I think your problem my be casued by [RT] , measure. You can try to add ALL, ALLSELECTED or ALLEXCEPT function in your measure. Or you can share a sample file with me and show me a screenshot with the result you want. This will make it easier for me to find the solution.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This problem was solved with help from @tamerj1 and you are correct, it was an issue with filter context in the [RT] that was solved by changing ALLSELECTED to ALL. Thank you for looking into this as well.
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 |