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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Ajibao03
Regular Visitor

How do I calculate a Total YTD Sales revenue with disconnected table in Power Bi

 
This formular below keeps returning the in the month sales revenue based on the disconnected table filter  instead of YTD sales revenue
 
YTDSelectedSalesRev = VAR SYTDx = TOTALYTD([Sales YTD],'SalesTable'[Date])
Return
CALCULATE((SYTDx),
FILTER(
    'SalesTable','SalesTable'[Date]="Disconnected Table Date")
    )
    )
1 ACCEPTED SOLUTION
v-denglli-msft
Community Support
Community Support

Thanks for the reply from AllisonKennedy, please allow me to provide another insight.
Hi @Ajibao03 ,

I am not sure how your semantic model is designed, here is my sample.
The SalesTable and the DisconnectedTable are as follows.

vdengllimsft_0-1736300963333.png

vdengllimsft_1-1736301024299.png


Then use the following measure to calculate Total YTD Sales revenue.

TotalYTD =
VAR _tb =
    DATESBETWEEN (
        'SalesTable'[Date],
        MINX ( ALL ( 'Disconnected Table' ), 'Disconnected Table'[Date] ),
        MAX ( 'Disconnected Table'[Date] )
    )
RETURN
    TOTALYTD ( SUM ( SalesTable[Amount] ), _tb )


The final result is as follows.

vdengllimsft_2-1736301252760.png

 

Please see the attached pbix for reference.

Best Regards,
Dengliang Li

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

3 REPLIES 3
v-denglli-msft
Community Support
Community Support

Thanks for the reply from AllisonKennedy, please allow me to provide another insight.
Hi @Ajibao03 ,

I am not sure how your semantic model is designed, here is my sample.
The SalesTable and the DisconnectedTable are as follows.

vdengllimsft_0-1736300963333.png

vdengllimsft_1-1736301024299.png


Then use the following measure to calculate Total YTD Sales revenue.

TotalYTD =
VAR _tb =
    DATESBETWEEN (
        'SalesTable'[Date],
        MINX ( ALL ( 'Disconnected Table' ), 'Disconnected Table'[Date] ),
        MAX ( 'Disconnected Table'[Date] )
    )
RETURN
    TOTALYTD ( SUM ( SalesTable[Amount] ), _tb )


The final result is as follows.

vdengllimsft_2-1736301252760.png

 

Please see the attached pbix for reference.

Best Regards,
Dengliang Li

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

Thanks. This works so well. @v-denglli-msft 

AllisonKennedy
Super User
Super User

@Ajibao03 

 

Variables are calculated where they are DEFINED. They are NOT calculated where they are called / used. So in your formula, the SYTDx is calculated in the default evaulation context of your visual you're using this measure in. The CALCULATE statement you're using isn't doing anything therefore. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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