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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors