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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
EdisonTrent
New Member

Show last data for each date

Hello,

I receive daily bank balances only if the bank balance changes (see the example)

EdisonTrent_0-1645204925805.png

I would like to show the graph and table for each day in the year showing the last bank balance (see below)

EdisonTrent_1-1645205022234.pngEdisonTrent_2-1645205082451.png

At this moment, if there are data only for one bank account, graph with total balance shows only balance on this account.

EdisonTrent_3-1645205607063.png

 

I spent hours to find solution online and would really appreciate your help.

 

Thank you

 

DateCityBank balance
01.01.2022New York47
01.01.2022London32
04.01.2022London51
06.01.2022New York36
06.01.2022London78
08.01.2022New York28
09.01.2022London65
11.01.2022New York89
11.01.2022London25
12.01.2022London34
14.01.2022New York61
14.01.2022London3
17.01.2022New York55
17.01.2022London38
19.01.2022London58
20.01.2022New York90
1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @EdisonTrent 

 

First you need to pivot column like this:

vjaneygmsft_0-1645512191947.png

Then you can create a new table and then create two columns to display what you want.

like this:

new table:

 

Table 2 = 
VAR Datelist =
    CALENDAR ( MIN ( 'Table'[Datefact] ), MAX ( 'Table'[Datefact] ) )
RETURN
    ADDCOLUMNS (
        Datelist,
        "New York",
            VAR a =
                MAXX (
                    FILTER ( ALL ( 'Table' ), [Datefact] <= [Date] && [New York] <> BLANK () ),
                    [Datefact]
                )
            RETURN
                MAXX ( FILTER ( ALL ( 'Table' ), [Datefact] = a ), [New York] ),
        "London",
            VAR a =
                MAXX (
                    FILTER ( ALL ( 'Table' ), [Datefact] <= [Date] && [London] <> BLANK () ),
                    [Datefact]
                )
            RETURN
                MAXX ( FILTER ( ALL ( 'Table' ), [Datefact] = a ), [London] )
    )

 

new column:

 

Total = 
VAR CurNewYork = [New York]
VAR CurLondon = [London]
VAR LastNewYork =
    MAXX (
        FILTER ( ALL ( 'Table 2' ), [Date] = EARLIER ( 'Table 2'[Date] ) - 1 ),
        [New York]
    )
VAR LastLondon =
    MAXX (
        FILTER ( 'Table 2', [Date] = EARLIER ( 'Table 2'[Date] ) - 1 ),
        [London]
    )
RETURN
    SWITCH (
        TRUE (),
        LastNewYork = BLANK ()
            || ( LastNewYork = [New York]
            && LastLondon = [London] )
            || LastNewYork <> [New York]
            && LastLondon <> [London], [New York] + [London],
        LastNewYork <> [New York]
            && LastLondon = [London], [New York] + LastLondon,
        LastNewYork = [New York]
            && LastLondon <> [London], LastNewYork + [London]
    )
Total2 = 
VAR CurNewYork = [New York]
VAR CurLondon = [London]
VAR LastNewYork =
    MAXX (
        FILTER ( ALL ( 'Table 2' ), [Date] = EARLIER ( 'Table 2'[Date] ) - 1 ),
        [New York]
    )
VAR LastLondon =
    MAXX (
        FILTER ( 'Table 2', [Date] = EARLIER ( 'Table 2'[Date] ) - 1 ),
        [London]
    )
RETURN
    SWITCH (
        TRUE (),
        LastNewYork = BLANK ()
            || LastNewYork <> [New York]
            && LastLondon <> [London], [New York] + [London],
        LastNewYork <> [New York]
            && LastLondon = [London], [New York],
        LastNewYork = [New York]
            && LastLondon <> [London], [London]
 
    )

 

vjaneygmsft_1-1645516027415.png

Did I answer your question? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

 

Best Regards,

Community Support Team _Janey

 

 

View solution in original post

5 REPLIES 5
EdisonTrent
New Member

Thank you very much for your help.

 

I wanted to ask you. How would you solve it if you had for example one hundred bank accounts and a new account can appear anytime in the future?

Hi, @EdisonTrent 

 

"If you had for example one hundred bank accounts and a new account can appear anytime in the future?"

 

I don't quite understand what it means. Since the calculation logic of your requirements is very complex, if your city values are only New York and London, then it is no problem to update the data normally, but if you want to add other cities, then the corresponding code should also be updated.

 

Best Regards,

Community Support Team _Janey

I would like to reword my question:

 

What if I had 100 cities and new city can appear any time in the data?

Hi, @EdisonTrent 

 

Obviously not, it can't have the exact same result you want.
It's very troublesome, you need to create a date table, establish relationship, and then write measure...

and that table visual is not available, maybe it can be displayed with matrix visual. In short, it is very complicated, mainly because your needs are not suitable for calculation on powerbi. 

 

Best Regards,

Community Support Team _Janey

v-janeyg-msft
Community Support
Community Support

Hi, @EdisonTrent 

 

First you need to pivot column like this:

vjaneygmsft_0-1645512191947.png

Then you can create a new table and then create two columns to display what you want.

like this:

new table:

 

Table 2 = 
VAR Datelist =
    CALENDAR ( MIN ( 'Table'[Datefact] ), MAX ( 'Table'[Datefact] ) )
RETURN
    ADDCOLUMNS (
        Datelist,
        "New York",
            VAR a =
                MAXX (
                    FILTER ( ALL ( 'Table' ), [Datefact] <= [Date] && [New York] <> BLANK () ),
                    [Datefact]
                )
            RETURN
                MAXX ( FILTER ( ALL ( 'Table' ), [Datefact] = a ), [New York] ),
        "London",
            VAR a =
                MAXX (
                    FILTER ( ALL ( 'Table' ), [Datefact] <= [Date] && [London] <> BLANK () ),
                    [Datefact]
                )
            RETURN
                MAXX ( FILTER ( ALL ( 'Table' ), [Datefact] = a ), [London] )
    )

 

new column:

 

Total = 
VAR CurNewYork = [New York]
VAR CurLondon = [London]
VAR LastNewYork =
    MAXX (
        FILTER ( ALL ( 'Table 2' ), [Date] = EARLIER ( 'Table 2'[Date] ) - 1 ),
        [New York]
    )
VAR LastLondon =
    MAXX (
        FILTER ( 'Table 2', [Date] = EARLIER ( 'Table 2'[Date] ) - 1 ),
        [London]
    )
RETURN
    SWITCH (
        TRUE (),
        LastNewYork = BLANK ()
            || ( LastNewYork = [New York]
            && LastLondon = [London] )
            || LastNewYork <> [New York]
            && LastLondon <> [London], [New York] + [London],
        LastNewYork <> [New York]
            && LastLondon = [London], [New York] + LastLondon,
        LastNewYork = [New York]
            && LastLondon <> [London], LastNewYork + [London]
    )
Total2 = 
VAR CurNewYork = [New York]
VAR CurLondon = [London]
VAR LastNewYork =
    MAXX (
        FILTER ( ALL ( 'Table 2' ), [Date] = EARLIER ( 'Table 2'[Date] ) - 1 ),
        [New York]
    )
VAR LastLondon =
    MAXX (
        FILTER ( 'Table 2', [Date] = EARLIER ( 'Table 2'[Date] ) - 1 ),
        [London]
    )
RETURN
    SWITCH (
        TRUE (),
        LastNewYork = BLANK ()
            || LastNewYork <> [New York]
            && LastLondon <> [London], [New York] + [London],
        LastNewYork <> [New York]
            && LastLondon = [London], [New York],
        LastNewYork = [New York]
            && LastLondon <> [London], [London]
 
    )

 

vjaneygmsft_1-1645516027415.png

Did I answer your question? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

 

Best Regards,

Community Support Team _Janey

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.