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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

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
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

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.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.