Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all -
I have searched all over and can't find a solution. I'm attaching sample data and a sample PBIX file.
I have a dataset with dates, times, accounts and amounts. Each account could have multiple transactions during the day. The times are essentially categorical in that they represent a period of time (all transactions between say 7:00 and 8:00). The goal is to compute a running total each day and then find the minimum of that total for each day and be able to graph that value. I can get it working when a single account or no account is selected in the slicer, but if more than one account is chosen, I do not get the correct minimum value.
My measures:
Total Amount = SUM(Table1[Amount])
Running Account Balance (all accounts) =
CALCULATE([Total Amount],
FILTER(
ALLEXCEPT('Table1','Table1'[Date]),
'Table1'[Time] <= MAX('Table1'[Time])
)
)
Running Account Balance =
CALCULATE([Total Amount],
FILTER(
ALLEXCEPT(Table1,'Table1'[Account],'Table1'[Date]),
'Table1'[Time] <= MAX('Table1'[Time])
)
)
Min Running Bal =
var MinRunningBalNoAccount = minx('Table1',[Running Account Balance (all accounts)])
var MinRunningBalAccount = minx('Table1',[Running Account Balance])
Return
IF(ISFILTERED('Table1'[Account]),
MinRunningBalAccount,
MinRunningBalNoAccount)
When I select a single account or not account, I get the correct Min Running Bal. But if I select multiple accounts I don't. What I really want is for DAX to sum the running total for all selected accounts and THEN figure out the minimum.
I hope it is clear what I am talking about, but I'm happy to provide more details if needed.
I hope these links to the files work!
Excel File
PBIX File
Solved! Go to Solution.
You need to take the minimum at the appropriate granularity.
Try this:
Min Running Balance =
VAR _Summary_ =
ADDCOLUMNS(
SUMMARIZE ( Table1, Table1[Date], Table1[Time] ),
"@RunBal", [Running Account Balance]
)
RETURN
MINX ( _Summary_, [@RunBal] )
You need to take the minimum at the appropriate granularity.
Try this:
Min Running Balance =
VAR _Summary_ =
ADDCOLUMNS(
SUMMARIZE ( Table1, Table1[Date], Table1[Time] ),
"@RunBal", [Running Account Balance]
)
RETURN
MINX ( _Summary_, [@RunBal] )
This is perfect!! Thank you, I've been looking for this exact solution for a couple of weeks.
Now, how would I pull the corresponding date of when the minimum running balance occurs?
You could filter the summary table for the minimum balance row(s) and take the date column from the filtered table.
Min Running Balance Date =
VAR _Summary_ =
ADDCOLUMNS (
SUMMARIZE ( Table1, Table1[Date], Table1[Time] ),
"@RunBal", [Running Account Balance]
)
VAR _MinBal =
MINX ( _Summary_, [@RunBal] )
RETURN
MINX ( FILTER ( _Summary_, [@RunBal] = _MinBal ), Table1[Date] )
Absolutely genius...Thank you!
Perfect! Thanks so much. I knew I was at the wrong granularity, just couldn't quite get it tow work. Appreciate the help!
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
9 | |
6 |