Calculating First Year Sales - with pics this time!

Hi All - I am attempting to show the Cumulative Sales for a Partner ONLY within the Calendar Year that the Partner registered . I have the following information in my model.

Partner Registration Date (New MRR Table)
Date (Calendar Table)
Cumulative Sales Measure (New MRR Table)

I have 3 years of daily sales data, 2018, 2019, and 2020.

My end goal is to show a Line Chart visual in which the Axis is the Month name, the Legend is the Partner Creation Year (2018, 2019, and 2020), and the Values are the Cumulative Sales of the partners.

I already have a Cumulative Sales measure which works properly. However, i don’t want the 2018 column to have any data in rows past Dec 2018. Here is an example of my table.

This is my measure for “First Year Sales,” which is not working as i had hoped.

I tried to use Sam’s method here. https://www.youtube.com/watch?v=JnhXyQ8eyuo

Any help is greatly appreciated. Sorry for a repeated topic!

Hi @acnyc88, we aim to consistently improve the topics being posted on the forum to help you in getting a strong solution faster. While waiting for a response, here are some tips so you can get the most out of the forum and other Enterprise DNA resources.

  • Use the forum search to discover if your query has been asked before by another member.

  • When posting a topic with formula make sure that it is correctly formatted to preformated text </>.

  • Use the proper category that best describes your topic

  • Provide as much context to a question as possible.

  • Include demo pbix file, images of the entire scenario you are dealing with, screenshot of the data model, details of how you want to visualize a result, and any other supporting links and details.

I also suggest that you check the forum guideline https://forum.enterprisedna.co/t/how-to-use-the-enterprise-dna-support-forum/3951. Not adhering to it may sometimes cause delay in getting an answer.

I wrote a sample query for you based on the data that i had in my system. Pls replace with your table name and column name and the sales table

Total Sale for Partner =
VAR FirstPurchaseDate =
MINX(FILTER(All(kpi_tblSales)
,kpi_tblSales[customerName]= “Partner”
),
kpi_tblSales[invoice_date]
)

return
if (Year(max(kpi_tblSales[invoice_date])) <> Year(FirstPurchaseDate),
    BLANK(),
CALCULATE([Total Sales],
    FILTER(All(kpi_tblSales), 
        Year(kpi_tblSales[invoice_date]) = Year(FirstPurchaseDate) &&
        kpi_tblSales[customerName]= "Partner" &&
        'kpi_tblSales'[invoice_date] <= MAX ( 'kpi_tblSales'[invoice_date] )
        
    )

))

this is what the result looks like

Does this help?

let me know if you have a follow up or feel free to attach yr pbix file
thanks.

Thanks for your help! However, I am unable to get your query to work in my scenario. It returns the below error. Not exactly sure where to go from here. I think I may need to create a new measure that displays the # of months since the partner’s creation date and try to go that route.

FYI - my measure “Net Sales” = SUM(Total Sales)

Total Sale for Partner =
var maxSalesInvoiceDate = MAX ( ‘kpi_tblSales’[invoice_date] )
VAR FirstPurchaseDate =
MINX(FILTER(All(kpi_tblSales)
,kpi_tblSales[customerName]= “Associated Buyers Inc”
),
kpi_tblSales[invoice_date]
)

return
if (Year(max(kpi_tblSales[invoice_date])) <> Year(FirstPurchaseDate),
    BLANK(),
CALCULATE([Total Sales],
    FILTER(All(kpi_tblSales), 
        Year(kpi_tblSales[invoice_date]) = Year(FirstPurchaseDate) &&
        kpi_tblSales[customerName]= "Associated Buyers Inc" &&
        'kpi_tblSales'[invoice_date] <= maxSalesInvoiceDate
        
    )

))

i made a slight change to the dax. can you pls try now with the updated DAX query. Esssentially i created a new VAR and used that variable in my filter function. Not sure why it was failing for you since it worked ok on my end, but this site helped me better understand your error message https://www.sqlgene.com/2019/04/16/dax-error-a-function-xxxx-has-been-used-in-a-true-false-expression-that-is-used-as-a-table-filter-expression-this-is-not-allowed/
if you still have a problem , can you attach the dax file and i can look into it.

thanks

@C9411010,

Thanks very much for your contributions on the forum - you’re posting a lot of great solutions. One tip - I think I know why the top half of your measures are not formatting properly. Try putting a hard return and a blank line in after the = sign on the first line of your measures. Your full measure should now format properly. It’s a quirk in the system that @Nick_M first told me about when I started posting here.

  • Brian
1 Like

Brian - Appreciate the feedback. Thank you.

Hi @acnyc88, a response on this post has been tagged as “Solution”. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the check box. Thanks!