Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nanma94
Helper III
Helper III

YTD of a dynamic measure

Each month we look at the rolling 3 months transactions to decide whats the total number of buying customers (if at least a unit is sold, this is an active buying customer). So here total nunmber of buying customers is a measure itself. 

 

M_AccountActiveCurrentMonth = if(Sales[M_Rolling3MonthTotalUnit]>0, 1, 0)

 

M_AccountActiveCountCurrentMonth = SUMX('SalesAccounts (buying acct)', [M_AccountActiveCurrentMonth])

 

Now I want to get YTD buying account growth comparing to last year YTD. How do I get to that?  - 

 

Capture.PNG

 

 

Thanks much!
NM

1 ACCEPTED SOLUTION

Hi,

 

You may refer to my solution in this file.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

11 REPLIES 11
v-shex-msft
Community Support
Community Support

Hi @nanma94,

 

You can use below formula to get YTD total:

M_AccountActiveCountCurrentMonth =
VAR currentDate =
    MAX ( 'SalesAccounts (buying acct)'[Date] )
RETURN
    SUMX (
        FILTER (
            ALLSELECTED ( 'SalesAccounts (buying acct)' ),
            [Date] <= currentDate
                && YEAR ( 'SalesAccounts (buying acct)'[Date] ) = YEAR ( currentDate )
        ),
        [M_AccountActiveCurrentMonth]
    )

If not help, please share some sample data for test.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft, thank you for your reply! but I need to ask further as I didnt explain the scenario clear enough last time.

 

According to the business rule, the YTD buying accounts is defined as the average of monthly buying accounts up to the current month. Lets say if we are looking at May YTD buying accounts growth comparing to 2017 - 

 

it should be -  avg(2018 Jan thru May monthly total as below) / avg(2017 Jan thru May monthly total as below)

 

"Sales" is a transaction table that has dates. 

"Sales Accounts (buying acct)" is another table that takes all distinct sales accounts from "Sales" table. 

 

I already have these 2 measures below - 

M_AccountActiveCurrentMonth = if(Sales[M_Rolling3MonthTotalUnit]>0, 1, 0)

 

M_AccountActiveCountCurrentMonth = SUMX('SalesAccounts (buying acct)', [M_AccountActiveCurrentMonth])

 

 

Capture.PNG

Hi,

 

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

What exacct result are you expecting.  Give me the exact numbers so that i can tally my formula's result with the numbers that you are expecting.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur


I was looking whole day but still struggling... Thank you for your help in advance:)

 

Capture.PNG

 

With this monthly accounts count above (as in the sample PBIX) , I am looking for 2018 May account growth as - 

 

divide

average YTD accounts in 2018: (2778+2709+3191+2778 + 3146) / 5

by

average YTD accounts in 2017: (926 + 995 + 1136 + 989 + 1010)/5

 

 

Hi,

 

You may refer to my solution in this file.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur

 

I guess I got excited too early...

 

in the sample, it works. but when I port over to my real file, YTD doesnt do rolling, it show the same # as the monthly count. 

 

I guess my customer count is too complex and it reference dates multiple times. 

 

As you see I have sales table, and account table. If in sales, rolling 3 months unit sold >0, the account in the account table is considered active (given value 1 in the measure than 0). Then for each specific month, I add up all the 1s to get to total active account count. 

 

Coming to do YTD, the monthly account count is already a complex measure referencing date multiple times...

 

 

To test, when I am not using this complex account count in YTD, but rather using a simple total revenue/unit measure, the YTD formula works. 

There is no image there.  Share the link from where i can download your PBI file and clearly tell me where the problem is.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur

it surely works. Thank you so much. 


I was on DATESYTD at the very beginning but I was trying to put sumx in front of the measure and never got out of it...

 

Again, thank you so much Ashish!

NM

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors