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
jockefe
Helper II
Helper II

YTD measure for month

I am using a SSAS OLAP as data source and have a couple of YTD measures which I want to use in Power BI

My PBI reports are all based on a month slicer (typically the business want to look at the data from a month perspective)

 

YTD are defined with the YTD MDX function shich means that I am using a date heirarchy year - month

 

This works all fine but it requires me to include a slicer for year (or a heirarchy slicer) in the report

If possible I want to remove the year slicer (space is pressures in the reports)

 

Any ideas?

Workarounds in PBI?

Posibble to define a YTD measure without teh YTD function?

6 REPLIES 6
SivaMani
Resident Rockstar
Resident Rockstar

@jockefe,

 

 

YTD will not work without year. Year To Date is related to year so it definetly required year to calculate YTD. We can't calculate YTD using only month, Right?

 

Hope, I made it clear.

Thanks, I understand that.

 

But given that I have a year - month field (e.g. 2017 january)

Are there any workarounds? either in Power BI or by changing the MDX

I think, no.

Because you have to use a year to calculate YTD. So whenever you try to filter the YTD based on Date, it needs year to calculated YTD for that particular period.

 

Let's say you have data for 2016 and 2017. You have calculated YTD.

You have month slicer.

For example, you selected Nov in the slicer. How do you whether it's Nov 2016 or Nov 2017.
How do you calculate the YTD without know the year?

 

Hope, I'm clear.

you are clear, thanks

 

But since the year-month field contains the year I thought it might be possible to extract the year from that field and use if for the YTD

Hi @jockefe,


But since the year-month field contains the year I thought it might be possible to extract the year from that field and use if for the YTD


If I understand you correctly, you should be able to create a new measure to calculate the YTD with the year-month field. The formula below is for your reference. Smiley Happy

measure_YTD =
VAR lastDay =
    MAX ( 'Date'[Date] )
VAR year =
    YEAR ( lastDay )
RETURN
    CALCULATE (
        SUM ( 'Table1'[Values] ),
        FILTER (
            ALL ( 'Date' ),
            YEAR ( 'Date'[Date] ) = year
                && 'Date'[Date] <= lastDay
        )
    )

 

Regards

thanks! That what I mean.

But I am using SSAS OLAP (Live connection) which means that I need to translaet that calculation ito MDX

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.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.