Forum Discussion

karthik_donthi's avatar
karthik_donthi
New Member
1 year ago

Actual vs Target

Dear Community,

 

I am currently modeling a report that needs me to prepare a graphic or a KPI card that would indicate actual values vs target values.

Actual values are reported with individual dates (individual orders), target values are defined yearly.

How do I model the data such that both change dynamically when I filter the years

 

Example:

Order 1 - 01.01.2023

Order 2 - 31.03.2023

Order 3 - 30.04.2023

.

.

.

Order N - 31.10.2024

Target:

2023 - 8 orders

2024 - 10 orders

 

Best regards
Karthik

7 Replies

  • Hi,

    I recommend creating a calendar table either in Power Query or Power BI using DAX. Once you have your calendar table ( a Year column/ a Month column/ a date column) , link it to your order table for both actual and target data.

    After setting up the calendar table, you can create a yearly slicer to display your actual and target data by year.

    Hope this helps!

  • First create a date table and mark it as a date table. There's plenty of articles and videos on that if you're unsure how to.

    Link the 'Date'[Date] to your orders table in a one-to-many relationship. Link 'Date'[Year] to your target table in a many-to-many relationship with a single direction so that 'Date' filters targets.

    You can then use the 'Date'[Year] column as a slicer or filter to only show data for the chosen year.

    You would need to create 3 measures like

    Num Orders = COUNTROWS( 'Orders' )
    
    Target Value = SUM( 'Targets'[Target] )
    
    Performance against target = DIVIDE( [Num Orders], [Target Value] )
  • Thanks for the hint. Any idea how to proceed if I have multiple KPIs and Targets,
    Example: Orders & Returns

    • tomorrowyw's avatar
      tomorrowyw
      New Member

      Hi, it doesn't matter if you have multiple KPIs and Targets. Having a calendar table in your data table is a must. xx

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,johnt75 and tomorrowyw .thanks for your concern about this issue.

    Your answers are excellent!
    And I would like to share some additional solutions below.
    Hello,karthik_donthi.I am glad to help you.
    johnt75 and tomorrowyw's suggestion is very good, creating a calendar table and creating joins will do what you need: calculate the number of Orders for each year.

    Here is my test data.
    01.01.2023 as date type
    If you have real data, the Date column is not a date type, but a text type, it doesn't affect the final result.
    You just need to use the left/right function with the find function to get the valid data of the date, and then use the date function to recreate the corresponding date column (using the dax code).
    Using Power Query for string splicing, you can achieve the same effect: create a new date column.

    1. Data conversion, the date column of the data in the ‘.’ Replace ‘.’ with ‘/’ in the data in the date column, and then convert it to date type in Power Query, and if there is an error, you can also do the type conversion in Power BI.

    Convert type to date

    Create a calendar table and add a column YearNum


    Create measure:

     

    M_YearOrderNum =
    CALCULATE (
        COUNT ( 'YearsOrder'[OrderID] ),
        FILTER (
            ALL ( 'YearsOrder' ),
            RELATED ( CalendarTable[YearNumber] ) = MAX ( 'CalendarTable'[YearNumber] )
        )
    )

     

    I've shared the pbix file for the test, I hope it helps!


    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Carson Jian,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.