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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Poulg
Frequent Visitor

DAX to get YTD for all the months until selected month with Month-year slicer

Hi, 

I have created a measure to get the YTD for the selected MMM-YY slicer below


YTD Sales = CALCULATE(SUM(Actual[Premium]),DATESYTD('Calendar'[Date])

I'm using MMM-YY slicer in my report. Also, Monthname from Calendar table in X-Axis, Y-Axis is YTD premium measure I have created.

Now, here when I select July-22, I want to get the Bar chart from Jan to July as I'm getting only July when I select Jul-22 in my MMM-YY slicer.
Please advise.


Thanks 

9 REPLIES 9
Poulg
Frequent Visitor

@amitchandak

 

Poulg
Frequent Visitor

Hi @Ashish_Mathur 

Thanks for the advice, But that is giving the value for the selected month only.
I want from January till the selected month.

similar post -Based on Month Slicer want to show YTD trend as Mo... - Microsoft Power BI Community





Share the download link of the PBI file.


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

Hi,

You do not need the YYYY-MM slicer.  To the X-axis, drag year and Month name from the Calendar Table.  Your measure is fine. 


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

@Poulg Better Year to Date Total - Microsoft Power BI Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

Thanks for the swift response to my post. 
But this video is just showing how to create YTD which doesn't meet my criteria.

Thanks.

@Poulg If I am understanding what you want, you would have to implement that as a disconnected date table for the slicer. That way you could get the MAX of that and zero out any thing that is beyond that date. Basically an extra IF statement at the end of the measure.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 
Same as this criteria. But, I'm using a Bar chart and MMM-YY slicer

I tried this but not working
Show Graph From First Month until filtered Month of the Year in Slicer -Power BI Tutorial (40/50) - ...

denxx34
Frequent Visitor

Hi @Poulg 

thx for the hint to the video... i have the same problem.

 

My solution:

 

1. Year&Month in the slicer from Filter-Date-Table to filter 

2. Year&Month in the visual from the normal Date-Table + the new measure

3. Filter-Date-Table is disconnected with other model

Measure:

 

YTD Turnover Filter =
VAR __ymax = YEAR( MAX( FilterDate[date] ) )
VAR __mmax = MONTH( MAX( FilterDate[date] ) )
VAR __dmax = MAX( FilterDate[date] )

RETURN
CALCULATE( [YTD Turnover] ,
    FILTER( Date , YEAR( Date[date] ) = __ymax
    && MAX( Date[monthnumber]) <= __mmax
    && MAX( Date[date] ) <= __dmax
    )
)

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.