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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Sachy123
Helper V
Helper V

Get latest Balance

I have a COA table which comes as a result of direct query in the following format.

DateIDCOABalance
1100150
1100260
21003100
2100130
3100280
4100360

 

In the Report, I would like to show all the COA;s with thier latest balances.

 

Latest Balance at DateID 4
COABalance
100130
100280
100360

 

What kind of Relationship shall I setup between the COA table and Date Dimension to show the report as above?

 

edit***

 

so after a lot of tries,, i somehow got it done by adding two measures for each COA as below

 

1001balance = var mindate=[minimum1001date] return CALCULATE(SUM(Data[Balance]),FILTER(all(Data),Data[DateID]=mindate && Data[COA]=1001))
 
minimum1001date = var dateselected=SELECTEDVALUE(Data[DateID]) return Maxx(FILTER(all(Data),Data[COA]=1001 && Data[DateID]<=dateselected),Data[DateID])
 
 
 
Screenshot_2.png

 

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Try like

LASTNONBLANKVALUE(Table[DateID], max(Table[Balance]))
Or
LASTNONBLANKVALUE(Table[DateID], sum(Table[Balance]))

 

Date Join should be on date ID. You can try using Date[Date] in place of Table[Date ID]

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

15 REPLIES 15
Ashish_Mathur
Super User
Super User

Hi,

Will you be selecting Data ID4 in the filter/slicer or do you want the DAX formula to pick up the last balance of each COA automatically?  Also, do you have actual date entries in the DateID column?  I'd request you to share the actual date format that you have in the DateID column.


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

Hi @Ashish_Mathur 

Yes will be selecting the dateid from the filter. well the date-id is coming via date dimension which has got format dd-mm-yyyy

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

Hi @Ashish_Mathur 

Thanks!   in your file the logic is working as expected.

but when I translate it in to my data, it throws me an error : An invalid numeric representation of a date value was encountered.

 

The date format in the date table was as follows 2016-06-13 00:00:00.000

 

Also , the COA data is a direct query..

Hi,

That does not look like a Date format.  In the Query Editor, ensure that you set the format of that column to Date.


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

@Ashish_Mathur  The transformation is not allowed in direct query to change column type. So the COA table is a result of direct query and the date dimension , I have pulled in the entire data set.

amitchandak
Super User
Super User

Try like

LASTNONBLANKVALUE(Table[DateID], max(Table[Balance]))
Or
LASTNONBLANKVALUE(Table[DateID], sum(Table[Balance]))

 

Date Join should be on date ID. You can try using Date[Date] in place of Table[Date ID]

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak

 

My version of powerbi does not support  LASTNONBLANKVALUE

still trying to figure out.. but how and where can i add the relationship?

 

rep.png

 

 

rel_1.png

 

does someone know what could be the solution? .. any hint would do!

Anonymous
Not applicable

Hi @Sachy123 ,

You can create a measure as below:

Latest Balance = 
VAR ccoa =
    MAX ( 'COA'[COA] )
RETURN
    SUMX (
        VALUES ( 'COA'[COA] ),
        CALCULATE (
            MAX ( 'COA'[Balance] ),
            FILTER ( 'COA', 'COA'[COA] = ccoa && 'COA'[DateID] = MAX ( 'COA'[DateID] ) )
        )
    )

latest balance.JPG

Best Regards

Rena

@Anonymous 

well,, the coa table is a direct query,,, so basically only pulls the data for that selected date,,, so i tried this measure but it didnt work 😞

Anonymous
Not applicable

Hi @Sachy123 ,

When select the DataID as 1, 2 or 3, what will display on the visual? Could you please explain the logic of display value? Thank you.

Best Regards

Rena

@Anonymous  The expected out put is as below

 

Latest Balance at DateID 4
  
COABalance
100130
100280
100360
  
  
  
Latest Balance at DateID     3
  
COABalance
100130
100280
1003100
  
  
Latest Balance at DateID    2
  
COABalance
100130
100260
1003100
  
Latest Balance at DateID   1
  
COABalance
100150
100260
10030

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors