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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Datafruit
Helper I
Helper I

Summarize a measure values

Hi 

I hope you can help me, been driving myself nuts with this while trying a whole lot of different options, searching for new ideas, etc., etc.
But here goes, I have this measure, that works great in the purpose I had it from the start - do display the latest value per ATM name in a Table visual.
But now when I would like to use that same measure in a line chart, it just displays the latest value and has no regard to the country, but rather displays only 1 latest value in the line chart.

 

Below I have put a snip of the dataI have.

Datafruit_1-1630219613096.png



The measure is below: 

Measure - ATM remaining balance = CALCULATE(
    FIRSTNONBLANK(bi_atm_customer_remaining_balance[atm_remaining_balance_without_reject],""),
    FILTER(bi_atm_customer_remaining_balance,MAX(bi_atm_customer_remaining_balance[les_transaction_started]))
    )

 

And what it currently looks like is here:

Datafruit_0-1630219532594.png

 

The total amount that should be displayed in the chart should be 14 273 000, but now it just displays one of those latest values.

 

The thing is that in the table the measure is correct. But in the line chart it does not summarize, which again is kinda correct, but not how I would want this too. I've tried countless of different options, but have come short. 

Can you guys help to get the summary of the latest values by ATMs per day?

 

 

 

1 ACCEPTED SOLUTION
daxer-almighty
Solution Sage
Solution Sage

I don't know your model, so I had to write such a mesaure in a model that I imagine there should be. A correct model.

 

// Your formula is incorrect for several reasons.
// One of them is that such a measure must return
// a number, not text. Also, your model needs to 
// be correct (think: star schema) to carry out
// correct and fast calculations.

ATM Balance =
var LastDateInContext = MAX( 'Dates'[Date] )
var Result =
    SUMX(
        DISTINCT( ATM[AtmID] ),
        // For each atm you should get the latest
        // amount in the current context, assuming
        // that 'Dates'[Date] is the column that
        // joins to your fact table (NetDailyTransactions)
        // on some NetDailyTransactions[Date] field.
        // I assume that the fact table
        // stores the net amount found in each atm
        // for any days where there were withdrawals
        // or fill-ups. Let's assume that the field
        // NetDailyTransactions[NetAmount] stores the
        // amount in the atm in question as recorded
        // at the end of such a day.
        MAXX(
            TOPN(1,
                CALCULATETABLE(
                    NetDailyTransactions,
                    // 'Dates' must be a proper date table
                    // in the model. See dax.guide/dateadd
                    // for guidance on how to build such
                    // a table.
                    'Dates'[Date] <= LastDateInContext,
                    ALLEXCEPT( NetDailyTransactions, ATM )
                ),
                NetDailyTransactions[Date],
                DESC
            ),
            NetDailyTransactions[NetAmount]
        )
    )
return
    Result

 

 

View solution in original post

2 REPLIES 2
daxer-almighty
Solution Sage
Solution Sage

I don't know your model, so I had to write such a mesaure in a model that I imagine there should be. A correct model.

 

// Your formula is incorrect for several reasons.
// One of them is that such a measure must return
// a number, not text. Also, your model needs to 
// be correct (think: star schema) to carry out
// correct and fast calculations.

ATM Balance =
var LastDateInContext = MAX( 'Dates'[Date] )
var Result =
    SUMX(
        DISTINCT( ATM[AtmID] ),
        // For each atm you should get the latest
        // amount in the current context, assuming
        // that 'Dates'[Date] is the column that
        // joins to your fact table (NetDailyTransactions)
        // on some NetDailyTransactions[Date] field.
        // I assume that the fact table
        // stores the net amount found in each atm
        // for any days where there were withdrawals
        // or fill-ups. Let's assume that the field
        // NetDailyTransactions[NetAmount] stores the
        // amount in the atm in question as recorded
        // at the end of such a day.
        MAXX(
            TOPN(1,
                CALCULATETABLE(
                    NetDailyTransactions,
                    // 'Dates' must be a proper date table
                    // in the model. See dax.guide/dateadd
                    // for guidance on how to build such
                    // a table.
                    'Dates'[Date] <= LastDateInContext,
                    ALLEXCEPT( NetDailyTransactions, ATM )
                ),
                NetDailyTransactions[Date],
                DESC
            ),
            NetDailyTransactions[NetAmount]
        )
    )
return
    Result

 

 

@daxer-almighty Thanks for your mightiness in DAX 🙂 
I used your logic and it works. Only changed the LastDateInContext from the date table date to my fact table datetime and it worked. 

Thanks a lot!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.