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
AndySawyer
Regular Visitor

Using a portion of a slicer

Hi,

 

I really hope someone can help me with this, as I'm new to DAX queries and I've been searching for the answer for hours with no results.

 

I have a slicer with a Month-Year picker, based off a Date table. I want to create a measure that will have the YTD for the current year selected, and also the prior comparable year, which can be displayed on a Stacked Column Chart in Power BI, with a separated column used in the Legend.

 

I have the following formula that work:

 

Total Revenue LYTD =
TOTALYTD(
SUM('Data'[Total Revenue]),
DATEADD('Date Start'[Date],-1,YEAR), "30/06"
)

 

Total Revenue CYTD =
TOTALYTD(
SUM('Data'[Total Revenue]),
'Date Start'[Date], "30/06"
)

 

But if I pull them both onto the chart, I can't use a third identifier (in this case a dimension named 'Market Segment') to color code the chart.

 

I'm figuring that I need to create a calculated measure that performs a YTD calculation for the Month portion of my slicer, ignoring the Year portion, so if the slicer has 'September 2017' selected, I could drag said measure onto the Value section of the chart, add the Market Segment dimension to the Legend and add the 'Date Start'[Financial Year] dimension to the Axis.

 

But I don't know how to do that! Help...

 

Regards,

 

Andy

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@AndySawyer,

 

Just add an appropriate measure and take advantage of Visual level filters.

http://community.powerbi.com/t5/Desktop/Relational-Date-Filter-By-Other-Date-How-To/td-p/298373

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you Sam,

 

However I'm trying to ensure that users only need to select one date slicer for one report. If I understand what you're suggesting, there would be two date slicers - one for this vis and one for all of the others - or the date would be filtered within the viz and would not change if the user changed the date slicer.

 

Andy

AndySawyer
Regular Visitor

Possibly worth mentioning, if I edit the interactions and remove the interaction between the slicer and the chart, I can get what I want with the following measure:

 

CALCULATE(TOTALYTD(
        SUM('Data'[Total Revenue]),
        'Date Start'[Date], "30/06"
    ),'Date Start'[MonthName] = "July")

 

However, I don't want to have to go in and change the month all the time. I want the month to be linked to the slicer (but I don't want the year linked to the slicer).

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.