Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kk1999
Regular Visitor

Trying to get a Year to Date field with a filter included.

I am trying to get a running total for orders with a specific description and have tried merging the YTD code with the filter code. I know both work individually, however together, the code just works like the filtering, (see the image; code is producing the dark blue "lines".) Any way to resolve this issues?

Sum of LineQty YTD 2 = 
IF(
    ISFILTERED('Sales Order with Line Detail'[CreatedOn]),
    ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
    TOTALYTD(
        SUM('Sales Order with Line Detail'[LineQty]),
        'Sales Order with Line Detail'[CreatedOn].[Date], FILTER('Sales Order with Line Detail', CONTAINSSTRING('Sales Order with Line Detail'[CustomerOrderNbr], " Subscription" ))
    )
)

 

Screenshot 2025-05-22 121838.png 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @kk1999  - you can create a separate calculated column with a flag, and filter based on it. 

eg: 

IsSubscription =
IF(CONTAINSSTRING('Sales Order with Line Detail'[CustomerOrderNbr], "Subscription"), 1, 0)

 

now, we can pass that flag in totalytd measure:

 

Sum of LineQty YTD 2 =
IF(
ISFILTERED('Sales Order with Line Detail'[CreatedOn]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
CALCULATE(
TOTALYTD(
SUM('Sales Order with Line Detail'[LineQty]),
'Sales Order with Line Detail'[CreatedOn]
),
'Sales Order with Line Detail'[IsSubscription] = 1
)
)

 

this work , please check





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
v-priyankata
Community Support
Community Support

Hi @kk1999 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

rajendraongole1
Super User
Super User

Hi @kk1999  - you can create a separate calculated column with a flag, and filter based on it. 

eg: 

IsSubscription =
IF(CONTAINSSTRING('Sales Order with Line Detail'[CustomerOrderNbr], "Subscription"), 1, 0)

 

now, we can pass that flag in totalytd measure:

 

Sum of LineQty YTD 2 =
IF(
ISFILTERED('Sales Order with Line Detail'[CreatedOn]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
CALCULATE(
TOTALYTD(
SUM('Sales Order with Line Detail'[LineQty]),
'Sales Order with Line Detail'[CreatedOn]
),
'Sales Order with Line Detail'[IsSubscription] = 1
)
)

 

this work , please check





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors