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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
mtrevisiol
Helper V
Helper V

Measure that calculates total sales up to today for a selected year

Hi everyone.

I've got a measure that calculates total sales from a FACT_MOV table. 

Then, I've got a slicer with the years (from 2011 to 2021). My goal would be to get the total sales from 1st January to today (17th June) related to the year selected in the slicer.

For example, if I select 2015, I would like to get Total sales from 01/01/2015 to 17th June 2015. Do you know what is the current formula to use in the measure?

Thank you.

1 ACCEPTED SOLUTION

Hi @mtrevisiol ,

 

If possible, please share your data with me, or provide some dummy data similar to your source data.

 

I'll try my best to help you.

 

Best Regards,

Stephen Tao

 

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

6 REPLIES 6
v-stephen-msft
Community Support
Community Support

Hi @mtrevisiol ,

 

First create a seperate(no relationship) year table by dax.

Table 2 = DISTINCT('Table'[Date].[Year])

Screenshot 2021-06-21 110004.pngScreenshot 2021-06-21 110020.png

 

Second create the measure

Filtered Date = CALCULATE(MAX('Table'[Date]),FILTER('Table',YEAR('Table'[Date])=SELECTEDVALUE('Table 2'[Year])&&[Date]<=DATE(SELECTEDVALUE('Table 2'[Year]),MONTH(TODAY()),DAY(TODAY()))))

Screenshot 2021-06-21 110111.png

 

 

Best Regards,

Stephen Tao

 

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

Thank you, but still doesn't work. I get "empty" even if a year is selected.

Hi @mtrevisiol ,

 

If possible, please share your data with me, or provide some dummy data similar to your source data.

 

I'll try my best to help you.

 

Best Regards,

Stephen Tao

 

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

Thank you for the help,  @v-syr . There was a problem with the interactions between visualizations I wasn't aware of.

Fowmy
Super User
Super User

@mtrevisiol 

You have a dates table, if not create one and link to your fact table. Then, you can use the TOTALYTD or TOTALYTD   functions

 

https://docs.microsoft.com/en-us/dax/totalytd-function-dax

https://docs.microsoft.com/en-us/dax/datesytd-function-dax

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you for the suggestion, but how can I use TOTALYTD for a year that is not the current one, but the selected one?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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