Forum Discussion
Need help with my measure
Hi abanar2 ,
Are the numbers in your post the expected results you want? If so, can you give an example of how to get this line of results in conjunction with your example data (REPLY 2)?
| 2021 | 1 | Site1 | % Training Done during the Quarter | 16.46% |
Best Regards,
Neeko Tang
| 2021 | 1 | Site1 | % Training Done during the Quarter | 16.46% |
=
Dividend row:
| Year | Quarter | Site_ID | KPI_ID | KPI_Name | Is_Total_KPI | KPI_Group | KPI_Value | Dividend_ID | Divisor_ID |
| 2021 | 1 | Site1 | KPI1 | Training Planned | Yes | % Training Done during the Quarter | 79 | KPI2 | KPI1 |
Divisor row:
| 2021 | 1 | Site1 | KPI2 | Training Done | No | % Training Done during the Quarter | 13 | KPI2 | KPI1 |
13 / 79 = 0.164556962
- Anonymous2 years agoNot applicable
Hi abanar2 ,
We can create two tables.
Table 2 = FILTER(SELECTCOLUMNS('Table',[Year],[Quarter],[Site_ID],[KPI_Name],[KPI_Value]),[KPI_Name] IN {"Training Planned","Number of Focus Rooms in the Office"})Table 3 = var _a=DISTINCT(SELECTCOLUMNS('Table',[Year],[Quarter],[Site_ID])) var _b={"% Training Done during the Quarter"} RETURN CROSSJOIN(_a,_b)We create a calculated column on Table 3.
Table_KPI_Value = var _a=CALCULATE(SUM('Table'[KPI_Value]),FILTER('Table',[Year]=EARLIER('Table 3'[Table_Year]) && [Quarter]=EARLIER('Table 3'[Table_Quarter]) && [Site_ID]=EARLIER('Table 3'[Table_Site_ID]) && [KPI_ID]="KPI1")) var _b=CALCULATE(SUM('Table'[KPI_Value]),FILTER('Table',[Year]=EARLIER('Table 3'[Table_Year]) && [Quarter]=EARLIER('Table 3'[Table_Quarter]) && [Site_ID]=EARLIER('Table 3'[Table_Site_ID]) && [KPI_ID]="KPI2")) RETURN DIVIDE(_b,_a)Then we can create a table.
Table 4 = var _a=SELECTCOLUMNS('Table 2',[Table_Year],[Table_Quarter],[Table_Site_ID],[Table_KPI_Name],[Table_KPI_Value]) var _b=SELECTCOLUMNS('Table 3',[Table_Year],[Table_Quarter],[Table_Site_ID],"Table_KPI_Name",[Value],[Table_KPI_Value]) RETURN UNION(_a,_b)Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- abanar22 years ago
Helper I
Hi Anonymous,
Thank you for your ideas.
In my real case I have about 50 KPI Groups and this number can change, so maybe in the future I will have less or more. I can`t hardcode anyting into my script because then it would be very painful to maintane.- Anonymous2 years agoNot applicable
Hi abanar2 ,
If you want to avoid hard-coding, you can modify the DAX expression like this:
Table 2 = FILTER(SELECTCOLUMNS('Table',[Year],[Quarter],[Site_ID],[KPI_Name],[KPI_Value]),[KPI_Name] IN SELECTCOLUMNS(FILTER('Table',[Is_Total_KPI]="Yes"),[KPI_Name]))Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.