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
Anonymous
Not applicable

Average of filter not giving the expected value

Hi,

 

I have two tables, what I want the column to do is to calculate the last value of the column number in the new column, given that I don't have the number for 2020 I am fixing the value of year in the second line of the formula. However the formula does not work as expected only working for the rows of 2019 not 2018,2020.

 

Cuadrante = IF(ISBLANK(CALCULATE(FIRSTNONBLANK(T2[NUMBER],TRUE()),FILTER(T2,T2[YEARDNI]=T1[YEARDNI]))),
CALCULATE(FIRSTNONBLANK(T2[NUMBER],TRUE()),FILTER(T2,T2[YEARDNI]=CONCATENATE("2019",T1[DNI]))),
CALCULATE(FIRSTNONBLANK(T2[NUMBER],TRUE()),FILTER(T2,T2[YEARDNI]=T1[YEARDNI])))

 

 

 

Table 1

YEARDNIYEARDNINEWCOLUMN
20201202018
20191201918
20181201813

 

Table 2

YEARDNIYEARDNINUMBER
12019201918
12018201813

 

Please your kind help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Ended up duplicating the data of the year 2019 and changing it to 2020. It works for now

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

I'm not sure I completely understand. Is the data you show the source data, expected output, both? Which is which? I do see in your formula that you hard coded "2019" so that probably explains why it is working for 2019 and not 2020 and 2018. You would need to replace that with something like [Year]?

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi,

 

Table 1 is the expected output, Table 2 is the source data. What I want it to do is to select the 2019 when there is no 2020 in the source data but when hardcoding it only works for the Table 1 Year 2019.

 

Thanks for the help,

 

Anonymous
Not applicable

Ended up duplicating the data of the year 2019 and changing it to 2020. It works for now

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.