cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Apply a ratio to the sales of last year.

Good ay to all,

Given the following measure used to compute the sales for last year:

Same Period Last Year = CALCULATE(
[Sales_Value],
SAMEPERIODLASTYEAR(
Date_DB[Date]))
And given a table called Target_tbl with two columns:
 
monthratio
1

100%

2100%
3

100%

4100%
5100%
625%
725%
835%
9 

10

 
11 
12 

 

Question, how to modify the measure to compute a targeted sales for each month based on the above?

Hence January this year is 100% or Jan last year, August this year is 35% of August last year.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: Apply a ratio to the sales of last year.

@Cyrilbrd , Calculate like

calculate(Max(Target[ratio])) *CALCULATE(
[Sales_Value],
SAMEPERIODLASTYEAR(
Date_DB[Date]))

 

Make sure both target and sales tables joined with the same date table. In case of the target table does not have date create date using month year.

First, few mins of this video has that -https://youtu.be/yPQ9UV37LOU

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Highlighted
Microsoft
Microsoft

Re: Apply a ratio to the sales of last year.

Hi @Cyrilbrd ,

 

You can set "2017" as a variable, and the template of the formula is similar to this.
In the measure, there is the concept of context, max (target)_ TBL [ratio]) represents the content of the current line.

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/ 

https://support.microsoft.com/en-us/office/context-in-dax-formulas-2728fae0-8309-45b6-9d32-1d600440a... 

https://www.microsoftpressstore.com/articles/article.aspx?p=2449191 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Super User IV
Super User IV

Re: Apply a ratio to the sales of last year.

@Cyrilbrd , Calculate like

calculate(Max(Target[ratio])) *CALCULATE(
[Sales_Value],
SAMEPERIODLASTYEAR(
Date_DB[Date]))

 

Make sure both target and sales tables joined with the same date table. In case of the target table does not have date create date using month year.

First, few mins of this video has that -https://youtu.be/yPQ9UV37LOU

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Highlighted
Microsoft
Microsoft

Re: Apply a ratio to the sales of last year.

Hi @Cyrilbrd ,

 

Try to create a measure like this:

this year sales =
CALCULATE (
    [Total Sales LY] * MAX ( Target_tbl[ratio] ),
    FILTER (
        Dates,
        Dates[Year] = 2017
            && MONTH ( Dates[Date] ) = MAX ( Target_tbl[month] )
    )
)

Sample .pbix

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Helper III
Helper III

Re: Apply a ratio to the sales of last year.

Hi Liang, in your solution the year is fixed to 2017 instead of being dynamically selected by the user via a series of visualization, any way to modify that, or shall i just use the first proposed solution (that works perfectly by the way).

What I do not uderstand is the use of MAX to call for the appropriate ratio, may I ask what is the reasoning behind? MAX is used in both proposed solutions.

 

Highlighted
Microsoft
Microsoft

Re: Apply a ratio to the sales of last year.

Hi @Cyrilbrd ,

 

You can set "2017" as a variable, and the template of the formula is similar to this.
In the measure, there is the concept of context, max (target)_ TBL [ratio]) represents the content of the current line.

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/ 

https://support.microsoft.com/en-us/office/context-in-dax-formulas-2728fae0-8309-45b6-9d32-1d600440a... 

https://www.microsoftpressstore.com/articles/article.aspx?p=2449191 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors