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
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]

 

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]

 

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!

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

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

@v-yiruan-msft 

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 😞

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

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

@v-yiruan-msft  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
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.