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

Translate Daily Balance into Daily movement

Hi All,

 

I have a table with Daily cash balance but I need to calculate daily movement by using ending balance minus beginning balance using DAX language.

 

For example, as below table, I want to know what is the daily movement for 2/1/2020 is 31-20 =11 for country A.

 

Could someone help with this please? I can't seem to find an option to upload the pbix file but I attach the demo table as below, thanks!

 

DateCountryBalance USD
1/1/2020A20
2/1/2020A31
3/1/2020A56
4/1/2020A87
5/1/2020A106
6/1/2020A156
7/1/2020A256
8/1/2020A366
9/1/2020A458
10/1/2020A510
11/1/2020A656
12/1/2020A784
13/1/2020A856
14/1/2020A925
1/1/2020B20
2/1/2020B25
3/1/2020B35
4/1/2020B50
5/1/2020B70
6/1/2020B95
7/1/2020B125
8/1/2020B160
9/1/2020B200
10/1/2020B245
11/1/2020B295
12/1/2020B350
13/1/2020B410
14/1/2020B475
4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @Setname ,

 

You can try my calculated column. The ALLEXCEPT function is to increase the company’s classification, you can also add other classifications yourself.

Daily = 
VAR tt =
    CALCULATE (
        MAX ( 'Table'[Balance USD] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Company], 'Table'[Country] ),
            [Date] < EARLIER ( 'Table'[Date] )
        )
    )
RETURN
    [Balance USD] - tt

9.png

 

 

Best Regards,

Stephen Tao

 

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

Setname
Frequent Visitor

Hi, bump up the thread, thanks for helping

amitchandak
Super User
Super User

@Setname , Try a new column like

 

Daily =
var _max =maxx(filter(Table, [country] = earlier([country]) && [Date] <earlier([Date])), [Date])
return
[Balance USD] - maxx(filter(Table, [country] = earlier([country]) && [Date] =_max), [Balance USD])

Thanks @amitchandak . I tried this in my real table in pbix and it doesn't seem to be correct...

In my fact table, there is actually more than 1 dimensions other than "Company", is it possible to create a new measure which can be put in to the graph or table and have different dimensions as slicers to show Daily movement in different scenarios?

 

Thanks!

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.