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
adnanarain
Helper V
Helper V

Need help to exclude data

Hi,

Result.PNG

I have data until May 2019. In the above picture, the x-axis is date difference in months, the legend is year and I am using a measure for values. I want to show the following:

1. For the year 2019, the line chart should only show result till 0 to 5

2. For the year 2018, the line chart should show the result till 0 to 17 (12 months of 2018 and 5 months of 2019)

3. For the year 2017, the line chart should show the result till 0 to 29 (24 months of 2018 and 2017 and 5 months of 2019) and so on.

 

Thanks in advance for the help.

 

 

2 ACCEPTED SOLUTIONS

I'd suggest adding a column to your table such as this, then filter your chart to "Yes":

 

DisplayOnlyValidPeriods = 
IF(Table1[Date Difference] <= (2019 - Table1[Account Open Year]) * 12 + 5,
    "Yes",
    "No"
)

 

Presumably, this is a data set that will be occasionally updated. As such, you'll probably want to update the hard-coded 2019... logic to something that uses the current year/month minus whatever lag you want to include in the reporting.

View solution in original post

@CoalesceIsMore Thank you so much for your answer. I have managed to get the desired result by using your calculated column but I have amended a little:

 

DisplayOnlyValidPeriods = 
IF('Main Query'[z. Date Difference From Account Open to Month] <= (Year(Max('Main Query'[Month_Start_Date]))-1 - 'Main Query'[Account_Open_Date - Year Only]) * 12 + 'Main Query'[Max month],
    "Yes",
    "No"
)

 

now I am planning to add a calculated table which will only store max month from my date. 

Thanks for all the help.

View solution in original post

11 REPLIES 11
adnanarain
Helper V
Helper V

please anyone who can help

I'd suggest adding a column to your table such as this, then filter your chart to "Yes":

 

DisplayOnlyValidPeriods = 
IF(Table1[Date Difference] <= (2019 - Table1[Account Open Year]) * 12 + 5,
    "Yes",
    "No"
)

 

Presumably, this is a data set that will be occasionally updated. As such, you'll probably want to update the hard-coded 2019... logic to something that uses the current year/month minus whatever lag you want to include in the reporting.

@CoalesceIsMore  Thanks for the reply. for 2019 I can use the max function to get a current year but for 5, the data will change every month so basically when I will add June data then the 5 becomes 6 and I have to change that every month. If 5 can be dynamic then it will be great help

@CoalesceIsMore with your logic i have managed to get the desired result but I don't know why it is showing like below: in the format tab the x-axis property set to CATEGORIAL.

 

Result.PNG

but when I change x-axis type property to CONTINOUS it shows like below: can I get x-axis number without skip

 

Result.PNG

To your first question (when you add June data then the 5 becomes 6), I don't think you'll be able to do that unless you either add the actual month number to your dataset, or if you can make an assumption about the latency of the data (e.g. it's always 14 months before today).

 

On your second question (sort order)... When you select the chart, you should see a ... at the right side of the chart (could be either upper or lower). Select that to ensure your Sort By is being done on your date diff. You may also need to confirm those are formatted as numbers so they don't have leading spaces that could be affecting it.

@CoalesceIsMore Thank you so much for your answer. I have managed to get the desired result by using your calculated column but I have amended a little:

 

DisplayOnlyValidPeriods = 
IF('Main Query'[z. Date Difference From Account Open to Month] <= (Year(Max('Main Query'[Month_Start_Date]))-1 - 'Main Query'[Account_Open_Date - Year Only]) * 12 + 'Main Query'[Max month],
    "Yes",
    "No"
)

 

now I am planning to add a calculated table which will only store max month from my date. 

Thanks for all the help.

PaulJ71
Regular Visitor

If I was in this scenario I'd probably try and apply those rules to my data source rather than in the report. I've made assumptions that the data is stored in a database and the additional data isn't used somewhere else within your report.

Thank you @PaulJ71  for the reply. My data stored in excel file and i am using that data in other visuals so i can not exclude data from my data source. I only want to apply this condition in this visual only.

Hi @adnanarain ,

 

Please show a sample data model.

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lionel-msft  below is the data I am using. I am uploading summarized data with measures:

 

Number of accounts is a simple count of account Numbers

 

Date Difference   Account Open Year   Number of Accts for Attrition   Attrition Calculation %
0201812290.00%
1201812240.41%
2201812240.41%
3201812101.55%
4201811873.42%
5201811724.64%
6201811744.48%
7201811595.70%
8201811565.94%
9201811427.08%
10201811357.65%
11201811407.24%
12201811308.06%
13201811308.06%
14201811268.38%
15201811228.71%
16201811129.52%
172018110510.09%
182018103515.79%
19201893723.76%
20201883432.14%
21201872441.09%
22201862748.98%
23201852257.53%
24201842965.09%
25201832373.72%
26201823181.20%
27201813289.26%
2820186994.39%
0201913780.00%
1201913740.29%
2201913660.87%
3201913502.03%
4201913283.63%
5201913095.01%
62019121411.90%
72019111019.45%
8201994931.13%
9201984039.04%
10201970548.84%
11201960356.24%
12201948464.88%
13201937173.08%
14201927779.90%
15201919186.14%
16201910192.67%

 

I am using the following measures:

 

 

Number of Accounts = COUNTA('Main Query'[Account_Number])
Attrition Difference # = 
var _lastrow=CALCULATE([Number of Accts for Attrition],FILTER(ALL('Main Query'[Date Difference]),'Main Query'[Date Difference]=0))
return

IF(ISBLANK(_lastrow),0,_lastrow-[Number of Accts for Attrition])
Attrition Calculation % = var _lastrow=CALCULATE([Number of Accts for Attrition],FILTER(ALL('Main Query'[Date Difference]),'Main Query'[Date Difference]=0))
return

if(DIVIDE([Attrition Difference #],_lastrow)=1, BLANK(), DIVIDE([Attrition Difference #],_lastrow))

 

 

I hope it is clear now, let me know if anything needed.

Thanks for the reply, I will upload soon.

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.