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
AishwariyaV
Helper IV
Helper IV

MTD, QTD, YTD Calculation

Hi,

I have calculated sales YTD, sales MTD and sales QTD. I have included separate slicers as YTD, MTD and QTD. 

If i select Year = 2010, Quarter = 3, my sales YTD has to show sales upto quarter 3 (i.e Q1,Q2 and Q3 sales) and my sales QTD has to show sales only for quarter 3.  Instead, in my report, when year  = 2010 and quarter = 3 is selected, Sales YTD and Sales QTD is showing the same value. Capture_LI.jpg 

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @AishwariyaV 

You may create slicer tables to achieve that.Make sure there's no relationships.Then you may create measures like below.Attached sample file for your reference.

Sales_QTD =
TOTALQTD (
    SUM ( 'Table'[Sales] ),
    'Table'[Date],
    FILTER (
        ALL ( 'Table' ),
        'Table'[Year] = SELECTEDVALUE ( Slicer_Year[Year] )
            && 'Table'[Qty] = SELECTEDVALUE ( Slicer_Qty[Qty] )
    )
)
Sales_QTD_Total = SUMX('Table',[Sales_QTD])
Sales_YTD = IF(SELECTEDVALUE(Slicer[TImeFrame])="YTD",TOTALYTD(SUM('Table'[Sales]),'Table'[Date],FILTER(ALL('Table'),'Table'[Year]=SELECTEDVALUE(Slicer_Year[Year])&&'Table'[Qty]<=SELECTEDVALUE(Slicer_Qty[Qty]))))
Sales_YTD_Total = SUMX('Table',[Sales_YTD])

Regards,

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

View solution in original post

1 REPLY 1
v-cherch-msft
Employee
Employee

Hi @AishwariyaV 

You may create slicer tables to achieve that.Make sure there's no relationships.Then you may create measures like below.Attached sample file for your reference.

Sales_QTD =
TOTALQTD (
    SUM ( 'Table'[Sales] ),
    'Table'[Date],
    FILTER (
        ALL ( 'Table' ),
        'Table'[Year] = SELECTEDVALUE ( Slicer_Year[Year] )
            && 'Table'[Qty] = SELECTEDVALUE ( Slicer_Qty[Qty] )
    )
)
Sales_QTD_Total = SUMX('Table',[Sales_QTD])
Sales_YTD = IF(SELECTEDVALUE(Slicer[TImeFrame])="YTD",TOTALYTD(SUM('Table'[Sales]),'Table'[Date],FILTER(ALL('Table'),'Table'[Year]=SELECTEDVALUE(Slicer_Year[Year])&&'Table'[Qty]<=SELECTEDVALUE(Slicer_Qty[Qty]))))
Sales_YTD_Total = SUMX('Table',[Sales_YTD])

Regards,

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

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.