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
Pfoerster
Helper III
Helper III

Struggling with YTD

Hello,

I am trying to build a report, which is showing me YTD sales until a choosen month. 

In my report, I am working with two tables, which are not linked (for some reasons concerning stock figures): one with all my information, second table only with month (Jan to Dec). 

Now, the user should be able to use the month slicer and choose for example july, and in the report, the July YTD Sales should occure. 

I am using following measure:

 

Actuals YTD = (VAR _Curr_month = SELECTEDVALUE('Monat'[Month])
return
calculate(sum(Combined[SalesVolume]),Filter(Combined,Combined[Scenario]="Actual"),FILTER(Combined,Combined[Type]="3rd"),Combined[Month] <= _Curr_month ))
 
This measure should select only actual figures and sales to 3rd partie for all month <= the choosen one. Unfortunately, as result I got figures, which do not make any sence and I absolutly have no idea, what is wrong. 
 
Thank you for any hint and help. 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Pfoerster , do you have date or if you can create date.

date = date([year],[month],1) //month is a number

How to do when it mmm or mmmm -https://youtu.be/yPQ9UV37LOU

 

Time intelligence

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

Power BI — YTD
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @Pfoerster ,

 

Try to redo your measure to:

Actuals YTD =
 (
    VAR _Curr_month =
        SELECTEDVALUE ( 'Monat'[Month] )
    RETURN
        CALCULATE (
            SUM ( Combined[SalesVolume] ),
            FILTER (
                Combined,
                Combined[Scenario] = "Actual"
                    && Combined[Type] = "3rd"
                    && Combined[Month] <= _Curr_month
            )
        )
)

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



amitchandak
Super User
Super User

@Pfoerster , do you have date or if you can create date.

date = date([year],[month],1) //month is a number

How to do when it mmm or mmmm -https://youtu.be/yPQ9UV37LOU

 

Time intelligence

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

Power BI — YTD
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Aye, perfect. That was a good advice:

I add a new column to my information table which gives me the number of Month (January = 1...). Then, I created another new measure, which transforms the selected month also into a number, and after that, the Sales Formular with <= works well. Thank you! 

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.