Forum Discussion
Create measure with cumulative objectives
Hi , Anonymous
Here are the steps you can refer to :
(1)This is my test data :
(2)We need to unpivot the table and add a flag column in Power Query Editor, you can put this in your "Advanced Editor" in your Power Query Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nfyUvDNzFPSUTIyJZeI1YlWCssszqxMLVZIKVXIzc8pBkqYQbEhSJWxAYgAsSxAQmAeEJuaweRAUkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [visites = _t, JAN = _t, FEB = _t, MAR = _t, APR = _t, MAY = _t, JUN = _t, JUL = _t, AUG = _t, SEP = _t, OCT = _t, NOV = _t, DEC = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"visites", type text}, {"JAN", Int64.Type}, {"FEB", Int64.Type}, {"MAR", Int64.Type}, {"APR", Int64.Type}, {"MAY", Int64.Type}, {"JUN", Int64.Type}, {"JUL", Int64.Type}, {"AUG", Int64.Type}, {"SEP", Int64.Type}, {"OCT", Int64.Type}, {"NOV", Int64.Type}, {"DEC", Int64.Type}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"visites"}, "Attribute", "Value"),
#"Added Conditional Column" = Table.AddColumn(#"Unpivoted Columns", "Custom", each if [Attribute] = "JAN" then 1 else if [Attribute] = "FEB" then 2 else if [Attribute] = "MAR" then 3 else if [Attribute] = "APR" then 4 else if [Attribute] = "MAY" then 5 else if [Attribute] = "JUN" then 6 else if [Attribute] = "JUL" then 7 else if [Attribute] = "AUG" then 8 else if [Attribute] = "SEP" then 9 else if [Attribute] = "OCT" then 10 else if [Attribute] = "NOV" then 11 else if [Attribute] = "DEC" then 12 else null, type number)
in
#"Added Conditional Column"
The table will convert to this:
(3)Then we apply the data to Desktop , and we can create a measure :
Measure = var _current_month = SELECTEDVALUE('Table'[Custom])
var _current_vis =SELECTEDVALUE('Table'[visites])
var _t =FILTER( ALLSELECTED('Table') ,'Table'[Custom] <= _current_month && 'Table'[visites] = _current_vis)
return
SUMX(_t,[Value])
(4)Then we can put the field on the visual we need , and we can sort the "Month" column by the [Custom] column , we can meet your need , the result is as follows:
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Anonymous3 years agoNot applicable
Hello v-yueyunzh-msft ,
Thanks again.
The measure works well but is not related to the right objectives.
When I put the measure on the graph, there is no results.
The column value should be dynamic : nb of employees which is on an other table * Objectives of the year (2 epr month per employees)
- v-yueyunzh-msft3 years ago
Community Support
Hi , Anonymous
Sorry,I don't understand what is "the measure is not related to the right objectives. "
According to your description, do you mean the [value] is generated by other table?
Can you give me sample test data as a table or .pbix file(without sensitive data) or update my test data to me ?
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly