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

Calculating YTD while keeping Month filter

I have bellow table data: 

 

SniperPro_7-1680791470582.png

 

I want to add a measure calculating the YTD of Value so I added this measure :

Mesure = CALCULATE(SUM('Table'[Value]), DATESYTD('Calendar'[Date]))

Then in my report I filtered on the month 202302, I have the correct result puting the month and the measure :

SniperPro_6-1680791372466.png

But when I add the product it's showing two lignes : 

SniperPro_4-1680791272920.png

How can I modify the measure to have just the filtered month 202302, the product2 and Measure ytd = 3.

6 REPLIES 6
FreemanZ
Super User
Super User

hi @SniperPro 

try like:

Mesure = 
CALCULATE(
     SUM('Table'[Value]),      DATESYTD('Calendar'[Date]),
     ALL('Table'[Product])
)
 
it seems you want to ignore the Product filter, but why adding it in the visual?

hello @FreemanZ 
I want to add a month filter on the report page level :

SniperPro_0-1680861302585.png

Then I want to see the product on this month (Product2) and the YTD Value on this month alose (3) 
Below the result that I want to see :

SniperPro_1-1680861529738.png

 

hi @SniperPro 

it is always adivisable to have a dimensional date table. Supposing you have one, then try like:

Measure2 = 
CALCULATE(
     SUM(TableName[Value]),      
     DATESYTD(DateTable[Date])
)

or 

Measure3 = 
TOTALYTD(
    SUM(TableName[Value]),
    DateTable[Date]
)

it worked like:

FreemanZ_2-1680870504008.png

hi @SniperPro 

try like:

 

Measure = 
CALCULATE(
     SUM(TableName[Value]),      
     YEAR(TableName[Date])=YEAR(MAX(TableName[Date])),
     TableName[Date]<=MAX(TableName[Date])
)

 

 

it worked like:

FreemanZ_1-1680870397075.png

 

@FreemanZ Is it possible to have this same formula using the date from the related calendar table and not from the TableName.

balafbm
Frequent Visitor

On the filter pane to the right, in the "Filters on this visual" section, under the Product column - > Choose Basic Filtering - > Then Choose "Product2"

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.

Top Solution Authors