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
admin11
Memorable Member
Memorable Member

How to remove target line from May till Dec 2021 ?

Hi All

I have sales vs target chart it work fine. 

I like to remove those target line from May till Dec , because May till Dec no sales yet , so don't need to display.

admin11_0-1619129454542.png

@Ashish_Mathur have share with me below code , it try to check if SALES_ is not blank , then compute the target line. 

TARGET_ = if(ISBLANK([SALES_]),BLANK(),SUM(TARGET_[TARGET]))

Since the sales vs target gap chart is using below expression :-

Target YTD =
var _max = today()
return
calculate(TOTALYTD(('TARGET_'[TARGET_]),'Date'[Date]),filter('Date','Date'[Date]<=_max))
So i try to convert the above expression to below :-
TARGET_YTD_ASHISG_ = if(ISBLANK([SALES_]),BLANK(),[Target YTD])
 
No error , but it does not work.
 
Hope some one can share with me where go wrong ?
 
My PBI file :-
 

Paul Yeo

1 ACCEPTED SOLUTION
samdthompson
Memorable Member
Memorable Member

Hello, I downloaded your pbix and replaced the Sales_YTD with this: It works for me

 

Sales YTD =

var _max = date(year(today())-0,month(today()),day(today()))
var val = TOTALYTD(('SALES'[SALES_]),dateadd('Date'[Date],-0,year),'Date'[Date]<=_max)
return
IF(TARGET_[TARGET_ASHISG_]=BLANK(),BLANK(),val)
 
 
// if this is a solution please mark as such. Kudos always appreciated.

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

I think this is happening because there is no relationship between the Source column of your Target Table and the Source column of your Source table.  I tried to create a relationship but could not.  Furthermore, i have also simplified some measures.  Download the PBI file from here.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
samdthompson
Memorable Member
Memorable Member

Hello, I downloaded your pbix and replaced the Sales_YTD with this: It works for me

 

Sales YTD =

var _max = date(year(today())-0,month(today()),day(today()))
var val = TOTALYTD(('SALES'[SALES_]),dateadd('Date'[Date],-0,year),'Date'[Date]<=_max)
return
IF(TARGET_[TARGET_ASHISG_]=BLANK(),BLANK(),val)
 
 
// if this is a solution please mark as such. Kudos always appreciated.

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.