Forum Discussion
Target Line
I have a table in which I have one column "Status" it is a string column containing 2 categorical values "Achieved" and "Not-Achieved" based on which I have calculated the count and percentage for both the categories. I want created a target line for upper and lower limit. I am displaying the data in month day wise format.
LOGIC: My logic for creating target line is that I want to check the top 3 values of each month here I have to consider 3 months for calculation. In the top 3 values of each month which is the lowest i.e the target line should cross atleast top 3 values of each month. And when new month is added it should take the new month data to calculate and not consider previous month.
FOR EXAMPLE: I have data from Aug to Dec and now Jan also I have started to add in it. To calculate the Target Line I will check the top 3 percentage in Aug, Sep, and Oct total 9 values and set the target line which will cross the 9 values in the chart. As now I have added Jan data the target line should consider Nov, Dec, and Jan values to set a new target.
Currently I have add target line manually:
Sample data:
- Anonymous1 year ago
Hi Anonymous ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a measure.
target = var _total=9 var _max_date=CALCULATE(MAX('Table'[Physical Vehicle Delivered Time]),ALLSELECTED('Table')) var _max_date_1=DATE(YEAR(_max_date),MONTH(_max_date),1) var _max_date_2=DATE(YEAR(EDATE(_max_date,-1)),MONTH(EDATE(_max_date,-1)),1) var _max_date_3=DATE(YEAR(EDATE(_max_date,-2)),MONTH(EDATE(_max_date,-2)),1) var _KPI_Yes1 = COUNTROWS(FILTER(ALLSELECTED('Table'),[KPI Status]="Achieved"&& [Physical Vehicle Delivered Time]>=_max_date_1 && [Physical Vehicle Delivered Time]<=_max_date_1+2)) var _KPI_Yes2 = COUNTROWS(FILTER(ALLSELECTED('Table'),[KPI Status]="Achieved"&& [Physical Vehicle Delivered Time]>=_max_date_2 && [Physical Vehicle Delivered Time]<=_max_date_2+2)) var _KPI_Yes3 = COUNTROWS(FILTER(ALLSELECTED('Table'),[KPI Status]="Achieved"&& [Physical Vehicle Delivered Time]>=_max_date_3 && [Physical Vehicle Delivered Time]<=_max_date_3+2)) RETURN (_KPI_Yes1+_KPI_Yes2+_KPI_Yes3)/_totalIn my test table, January 2025 is the most recent data, so the calculations are for attainment from the 1st through the 3rd of each month for January 2025, December 2024, and November 2024, and based on your description of three months and three dates then the total is 9.
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
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.
3 Replies
- danextian
Super User
Hi Anonymous
If you're sharing a sample, please ensure it's in a usable format (not an image). You can post a link to a sanitized copy of your .pbix or Excel file. Make sure the sample data is complete. Explain how to utilize the sample data—how does the second screenshot connect to the percentages in the first? Demonstrate your expected result using the same sample data and provide the reasoning behind it.
- AnonymousNot applicable
I have used KPI_Status column to calculate the count and percentage of "Achieved".
Count formula:
KPI_Yes = CALCULATE(COUNT(DUMP[Status]),DUMP[Status] = "Achieved")
Percentage formula:Achieved% = [KPI_Yes]/[Total]KPI_Status is defined by "TAT wrt FRM" if it is less than 0 then "not-achieved" else "achieved". I have plotted the graph based on "Physical Vehicle Delivered Time" month and day in x-axis and percentage in y-axis. Now I want to plot dynamic target line so that when any filter is applied the target line changes according to it.Below is the Sample Table:Short Dicv Regional Office Pre Order Date Physical Vehicle Delivered Time STD FRM FRM+3H TAT TAT wrt FRM KPI Status Month ABUTANI EAST1 09-09-2024 09:21 08-10-2024 12:03 14.0 17.0 698.7 -681.7 Not Achieved Oct'24 ABUTANI EAST1 25-09-2024 10:17 03-10-2024 18:16 19.1 22.1 200.0 -177.9 Not Achieved Oct'24 ABUTANI EAST1 27-09-2024 09:53 01-10-2024 18:33 19.9 22.9 104.7 -81.8 Not Achieved Oct'24 ABUTANI EAST1 30-09-2024 09:41 01-10-2024 15:48 1.8 4.8 30.1 -25.3 Not Achieved Oct'24 ABUTANI EAST1 01-10-2024 09:39 03-10-2024 09:13 9.3 12.3 47.6 -35.3 Not Achieved Oct'24 ABUTANI EAST1 30-09-2024 10:29 07-10-2024 11:57 1.0 4.0 169.5 -165.5 Not Achieved Oct'24 ABUTANI EAST1 01-10-2024 09:40 01-10-2024 12:23 0.5 3.5 2.7 0.8 Achieved Oct'24 ABUTANI EAST1 01-10-2024 09:36 03-10-2024 20:29 2.2 5.2 58.9 -53.7 Not Achieved Oct'24 ABUTANI EAST1 01-10-2024 13:03 01-10-2024 17:52 6.5 9.5 4.8 4.7 Achieved Oct'24 ABUTANI EAST1 01-10-2024 11:40 01-10-2024 17:13 1.0 4.0 5.6 -1.6 Not Achieved Oct'24 ABUTANI EAST1 01-10-2024 13:07 01-10-2024 18:37 0.0 3.0 5.5 -2.5 Not Achieved Oct'24 ABUTANI EAST1 01-10-2024 17:59 01-10-2024 18:08 0.0 3.0 0.2 2.8 Achieved Oct'24 ABUTANI EAST1 03-10-2024 09:40 03-10-2024 12:54 0.7 3.7 3.2 0.5 Achieved Oct'24 ABUTANI EAST1 01-10-2024 15:16 05-10-2024 12:37 7.1 10.1 93.4 -83.3 Not Achieved Oct'24 ABUTANI EAST1 03-10-2024 09:37 03-10-2024 18:22 0.2 3.2 8.8 -5.6 Not Achieved Oct'24 ABUTANI EAST1 03-10-2024 09:56 03-10-2024 17:12 1.6 4.6 7.3 -2.7 Not Achieved Oct'24 TOPSEL EAST1 01-10-2024 09:53 01-10-2024 16:36 4.0 7.0 6.7 0.3 Achieved Oct'24 TOPSEL EAST1 01-10-2024 09:07 01-10-2024 14:54 5.5 8.5 5.8 2.7 Achieved Oct'24 TOPSEL EAST1 01-10-2024 09:05 01-10-2024 18:20 15.0 18.0 9.2 8.8 Achieved Oct'24 TOPSEL EAST1 01-10-2024 10:16 01-10-2024 18:04 14.3 17.3 7.8 9.5 Achieved Oct'24 TOPSEL EAST1 01-10-2024 08:42 01-10-2024 16:50 1.6 4.6 8.1 -3.5 Not Achieved Oct'24
- AnonymousNot applicable
Hi Anonymous ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a measure.
target = var _total=9 var _max_date=CALCULATE(MAX('Table'[Physical Vehicle Delivered Time]),ALLSELECTED('Table')) var _max_date_1=DATE(YEAR(_max_date),MONTH(_max_date),1) var _max_date_2=DATE(YEAR(EDATE(_max_date,-1)),MONTH(EDATE(_max_date,-1)),1) var _max_date_3=DATE(YEAR(EDATE(_max_date,-2)),MONTH(EDATE(_max_date,-2)),1) var _KPI_Yes1 = COUNTROWS(FILTER(ALLSELECTED('Table'),[KPI Status]="Achieved"&& [Physical Vehicle Delivered Time]>=_max_date_1 && [Physical Vehicle Delivered Time]<=_max_date_1+2)) var _KPI_Yes2 = COUNTROWS(FILTER(ALLSELECTED('Table'),[KPI Status]="Achieved"&& [Physical Vehicle Delivered Time]>=_max_date_2 && [Physical Vehicle Delivered Time]<=_max_date_2+2)) var _KPI_Yes3 = COUNTROWS(FILTER(ALLSELECTED('Table'),[KPI Status]="Achieved"&& [Physical Vehicle Delivered Time]>=_max_date_3 && [Physical Vehicle Delivered Time]<=_max_date_3+2)) RETURN (_KPI_Yes1+_KPI_Yes2+_KPI_Yes3)/_totalIn my test table, January 2025 is the most recent data, so the calculations are for attainment from the 1st through the 3rd of each month for January 2025, December 2024, and November 2024, and based on your description of three months and three dates then the total is 9.
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
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.