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
vaspiliop
Frequent Visitor

Cumulative YTD only for the current week on visual (x-axis)

Hello,

 

I use the below DAX for a YTD  cumulative and it works fine. Dates are well linked and when i drill-down to week or select it works fine.

 

YTD = calculate(sum(Orders[Orders]),filter(all('Orders'),'Orders'[calendarWeek]<=max('Orders'[calendarWeek])))
 
The issue I have is that I would like to show on the below graph with the same calculation only the August bar, without unfiltering Jan-July (need to use this measure in another graph too , where Jan-July have other measures)
 
pbi.jpg
 
Can you please advise how could i do that? Tried some filter functions without success.
 
Many thanks!
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@vaspiliop ,

YTD = calculate(sum(Orders[Orders]),filter(all('Orders'),'Orders'[calendarWeek]<=max('Orders'[calendarWeek])))

 

Check if this can work

Last Month YTD = var _max =maxx(ALLSELECTED('Date'),'Date'[Month Year])
return
CALCULATE([YTD],FILTER('Date','Date'[Month Year]=_max))

View solution in original post

3 REPLIES 3
v-xicai
Community Support
Community Support

Hi @vaspiliop ,

 

You may create column and measure like DAX below, and put [Max Month YTD] into Values box of chart visual.

 

 

Column:

YearMonth = VALUE(FORMAT('Orders'[Date],"yyyymm"))


Measure:

Max Month YTD =
VAR _MaxYearMonth =
    CALCULATE ( MAX ( 'Orders'[YearMonth] ), ALLSELECTED ( 'Orders' ) )
RETURN
    IF (
        MAX ( 'Orders'[YearMonth] ) = _MaxYearMonth,
        CALCULATE ( [YTD], FILTER ( 'Orders', 'Orders'[YearMonth] = _MaxYearMonth ) ),
        BLANK ()
    )

 

 

>>to keep some  filters   working?  since the ALL function clears filters also from other fields where i would need them to still filter.

 

In addition , for this question, you could change the ALL function to ALLSELECTED function.

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

amitchandak
Super User
Super User

@vaspiliop ,

YTD = calculate(sum(Orders[Orders]),filter(all('Orders'),'Orders'[calendarWeek]<=max('Orders'[calendarWeek])))

 

Check if this can work

Last Month YTD = var _max =maxx(ALLSELECTED('Date'),'Date'[Month Year])
return
CALCULATE([YTD],FILTER('Date','Date'[Month Year]=_max))

Many thanks @amitchandak  , appreciate your help! this actually solved it - just one more question please

 

is there a way for this formula:

 

YTD = calculate(sum(Orders[Orders]),filter(all('Orders'),'Orders'[calendarWeek]<=max('Orders'[calendarWeek])))

 

to keep some  filters   working?  since the ALL function clears filters also from other fields where i would need them to still filter.

 

thanks

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.