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.
Hello,
I have a table with the following structure:
Year_Month | Type | Value |
2023.01 | Production | 5 |
2023.01 | Production_Target | 7 |
2023.01 | Compliance | 8 |
2023.01 | Compliance_Target | 8 |
2023.02 | Production | 10 |
2023.02 | Production_Target | 12 |
2023.02 | Compliance | 4 |
2023.02 | Compliance_Target | 6 |
2023.03 | Production | 15 |
2023.03 | Production_Target | 13 |
2023.03 | Compliance | 11 |
2023.03 | Compliance_Target | 12 |
Rows where the Type column has the value "_Target" indicate that they are rows with target values for the respective Indicator Type (for example, the type "Production" is the actual production value for each month and the "Production-Target" is the expected value for each month). I want to create charts for each Type that show the actual value for each month and a goal line (which shows the "_Target" values for each month), but I'm not able to turn this table into a better way.
My expected table result would be this:
Year_Month | Type | Value | Objective |
2023.01 | Production | 5 | 7 |
2023.02 | Production | 10 | 12 |
2023.03 | Production | 15 | 13 |
2023.01 | Compliance | 8 | 8 |
2023.02 | Compliance | 4 | 6 |
2023.03 | Compliance | 11 | 12 |
Solved! Go to Solution.
Hi @req77 ,
Here are the steps you can follow:
1. In Power Query -- Add Column – Index Column – From 1.
2. Create calculated column.
Group =
MINX(
FILTER(ALL('Table'),'Table'[Year_Month]=EARLIER('Table'[Year_Month])),[Index])
Type_Group =
IF(
CONTAINSSTRING('Table'[Type],"Production_Target")=TRUE()
||
CONTAINSSTRING('Table'[Type],"Compliance_Target")=TRUE()
,0,1)
Sum =
SUMX(
FILTER(ALL('Table'),
'Table'[Index]<=EARLIER('Table'[Index])),[Type_Group])
Rank =
RANKX(
FILTER(ALL('Table'),
'Table'[Group]=EARLIER('Table'[Group])&&'Table'[Sum]=EARLIER('Table'[Sum])),[Index],,ASC)
Objective =
IF(
[Rank]=
MINX(
FILTER(ALL('Table'),'Table'[Sum]=EARLIER('Table'[Sum])),[Rank]),
SUMX(
FILTER(ALL('Table'),
'Table'[Sum]=EARLIER('Table'[Sum])&&'Table'[Rank]=
MAXX(
FILTER(
ALL('Table'),'Table'[Sum]=EARLIER('Table'[Sum])),[Rank])),[Value]
))
3. Create calculated table.
Table 2 =
var _table=FILTER('Table',[Rank]=1)
return
SUMMARIZE(
_table,[Year_Month],[Type],[Value],[Objective])
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @req77 ,
Here are the steps you can follow:
1. In Power Query -- Add Column – Index Column – From 1.
2. Create calculated column.
Group =
MINX(
FILTER(ALL('Table'),'Table'[Year_Month]=EARLIER('Table'[Year_Month])),[Index])
Type_Group =
IF(
CONTAINSSTRING('Table'[Type],"Production_Target")=TRUE()
||
CONTAINSSTRING('Table'[Type],"Compliance_Target")=TRUE()
,0,1)
Sum =
SUMX(
FILTER(ALL('Table'),
'Table'[Index]<=EARLIER('Table'[Index])),[Type_Group])
Rank =
RANKX(
FILTER(ALL('Table'),
'Table'[Group]=EARLIER('Table'[Group])&&'Table'[Sum]=EARLIER('Table'[Sum])),[Index],,ASC)
Objective =
IF(
[Rank]=
MINX(
FILTER(ALL('Table'),'Table'[Sum]=EARLIER('Table'[Sum])),[Rank]),
SUMX(
FILTER(ALL('Table'),
'Table'[Sum]=EARLIER('Table'[Sum])&&'Table'[Rank]=
MAXX(
FILTER(
ALL('Table'),'Table'[Sum]=EARLIER('Table'[Sum])),[Rank])),[Value]
))
3. Create calculated table.
Table 2 =
var _table=FILTER('Table',[Rank]=1)
return
SUMMARIZE(
_table,[Year_Month],[Type],[Value],[Objective])
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
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 |
---|---|
111 | |
95 | |
80 | |
68 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |