Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago

Group Daily Target by Month and compare Weekly Sales

Hi,

 

This seems like it should be straight forward however I am at a bit of a loss.

 

I have three tables. A Sales table, a Date table and a Target table.

NOTE: date = 1/1/2017, 1/2/2017, etc...

 

My sales is split by date/region/store/order ID/Product ID/etc.
My targets are split by date/region/store.

My date table has the date period and every view of date that I need, Month/Year/MonthYear/Week/etc.

I have scoured forums and tried quite a few solutions to no avail and I feel I am missing a basic concept or formula with DAX.

 

Essentially my table is as below:

WeekMonthSalesTargetAchieved%
1110011090.9%
2146750093.4%
31254230110.4%
41125120104.2%
52155150103.3%
6223525094.0%
7215225060.8%
8219220096.0%
93585550106.4%
103867500173.4%
113931700133.0%
12334360057.2%

 

 

And I want it to look like this

WeekMonthSalesTargetContribution %
1110096010.4%
2146796048.6%
3125496026.5%
4112596013.0%
5215585018.2%
6223585027.6%
7215285017.9%
8219285022.6%
93585235024.9%
103867235036.9%
113931235039.6%
123343235014.6%

 

I am not sure if anyone will be able to help me understand a level further in addition to this, however as a Qlik user - I would be able to aggregate any expression and aggregate as required by using AGGREGATE,
e.g. Target_byMonth = AGGREGATE(SUM(Target),[Month Number]) #this gives me a virtual table of summed target by month no..
Then I could simply compare write SUM(Sales) / Target_byMonth and it would return the second table as above.
What is the equivalent in DAX so that I can aggregate my measures by any dimension I want?

 

Thanks and much appreciated for help!

2 Replies

  • anandav's avatar
    anandav
    Icon for Skilled Sharer rankSkilled Sharer

    Anonymous,

     

    Try below measures.

     

    Target Cummulative by Month =
    CALCULATE(
        SUM(Table1[Target]),
        FILTER(ALLEXCEPT(Table1, Table1[Month]), Table1[Week] <= Table1[Week])
    )

     

    New Percentage =
    MIN(Table1[Sales]) / [Target Cummulative by Month]

     

    (Format the above as Percentage)

     

     

    Hope this helps.

     

    If this solves your problem please mark as solution.

    • Anonymous's avatar
      Anonymous
      Not applicable

      anandav

       

      Thanks for replying. It works in the table format using dates from the target table. However I need to use the Calendar table and in a line chart that displays by week (not month), however these are what I'm finding. Could this be an issue with my data model?

      I have the Target table linked to my Calendar table (by date which works) and the target table linked to my 'Master Store Table' and both the Calendar and Master Store table are related to my data model? However note my targets work when summing the day without creating the measure you have as below which makes me think it's not the model but the calc? See below for reference.