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
JohnD2
Frequent Visitor

Get 6 bars with last values of 6 months

Hi all,

In previous posts the following was discussed:

 

http://community.powerbi.com/t5/Desktop/DAX-formula-to-return-data-for-last-6-months/m-p/50455#M2019...

 

Thanks for the comments on this, it is very valueable.

 

When i use this solution on my table, it sums all the values.
In my situation i want to have the last value available for the 6 different months

I used in a calculated table the following calculated column:
MaxDate = MAXX(RELATEDTABLE(TestBalances);TestBalances[Date])

The only problem here is that it takes the very last value, of a range of dates.

I want to have the last value of a month

date table sample:
date yearmonthnumber
01-jan-2016 2016_01
02-jan-2016 2016_01
..
31-jan-2016 2016_01
01-feb-2016 2016_02
...

balance table sample:
date balance type
01-jan-2016 2000 Green
15-jan-2016 2005 Green
26-jan-2016 2009 Green
01-feb-2016 2100 Green
15-feb-2016 2105 Green
24-feb-2016 2109 Green
01-mch-2016 2200 Green
15-mch-2016 2205 Green
17-mch-2016 2209 Green

The result that I want to have is:
26-jan-2016 2009 Green
24-feb-2016 2109 Green
17-mch-2016 2209 Green

Important note: when there is no value of the balance for a month, it should take the last available balance.
Any suggestions?
John

1 REPLY 1
v-micsh-msft
Employee
Employee

Hi JohnD2,

Could you please share a screenshot of the table under the relationship View?

I am afraid currently I am not able to figure which one is the table of TestBalances.

From my understanding, we could take use of Earlier function to locate the month value.

What we need to do is to  create another Year-month column on TestBalances table, then the calculated column shoud be the formula as below:

MaxDate = Calculate(

                             MAXX(RELATEDTABLE(TestBalances);

                                         TestBalances[Date]),

                             Filter(Relatedtable(TestBalances),

                                      TestBalances[Year-month]=earlier(TestBalances[Year-month])))

I haven't tested it yet, please share the data model or data example here, so I could suggest a more suitable expression.

Regards

 

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.

Top Solution Authors