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
Need assistance I am trying to find the Max based on another column although I want the values to be summed depending on the depots filtered.
Example Data
Depot | Date | Time | Value 1 | Value 2 |
CAL | 18-Aug | 10:00AM | 10 | 0 |
CAL | 18-Aug | 11:00AM | 10 | 1 |
CAL | 18-Aug | 12:00PM | 20 | 2 |
CAL | 18-Aug | 1:00PM | 20 | 9 |
CAL | 18-Aug | 2:00PM | 15 | 3 |
MARC | 18-Aug | 10:00AM | 11 | 3 |
MARC | 18-Aug | 11:00AM | 15 | 4 |
MARC | 18-Aug | 12:00PM | 21 | 1 |
MARC | 18-Aug | 1:00PM | 21 | 7 |
MARC | 18-Aug | 2:00PM | 3 | 8 |
CAL | 19-Aug | 10:00AM | 10 | 2 |
CAL | 19-Aug | 11:00AM | 10 | 4 |
CAL | 19-Aug | 12:00PM | 20 | 1 |
CAL | 19-Aug | 1:00PM | 20 | 8 |
CAL | 19-Aug | 2:00PM | 15 | 3 |
MARC | 19-Aug | 10:00AM | 11 | 2 |
MARC | 19-Aug | 11:00AM | 15 | 1 |
MARC | 19-Aug | 12:00PM | 21 | 2 |
MARC | 19-Aug | 1:00PM | 21 | 5 |
MARC | 19-Aug | 2:00PM | 3 | 0 |
At a total level return Value 2 based on the Max Value 1. These Values should be summed if multiple depots are filtered.
What I am trying to acheive in a matrix with a depot filter
Date | Time | Value 1 | Value 2 | |
18-Aug | 10:00AM | 21 | 3 | |
18-Aug | 11:00AM | 25 | 5 | |
18-Aug | 12:00PM | 41 | 3 | |
18-Aug | 1:00PM | 41 | 16 | |
18-Aug | 2:00PM | 18 | 11 | |
Total | 18-Aug | 41 | 16 | |
19-Aug | 10:00AM | 21 | 4 | |
19-Aug | 11:00AM | 25 | 5 | |
19-Aug | 12:00PM | 41 | 3 | |
19-Aug | 1:00PM | 41 | 13 | |
19-Aug | 2:00PM | 18 | 3 | |
Total | 19-Aug | 41 | 13 |
Solved! Go to Solution.
@LLP515 , First create a measure for MAX Value 1
Proud to be a Super User! |
|
Hi @LLP515 ,
Thanks bhanu_gautam for the quick reply. I have some other thoughts to add:
(1)We can create measures.
Measure1 = CALCULATE(SUM('Table'[Value 1]),FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] in VALUES('Table'[Time])))
Value1 =
var _a=CALCULATE(SUM('Table'[Value 1]),FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] in VALUES('Table'[Time])))
var _b=MAXX(FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] in VALUES('Table'[Time])),[Measure1])
var _c=IF(ISINSCOPE('Table'[Time])=FALSE(),_b,_a)
RETURN _c
Value2 =
var _a=SUM('Table'[Value 2])
var _max=MAXX(FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] in VALUES('Table'[Time])),[Measure1])
var _b=CALCULATE(MAX('Table'[Time]),FILTER(ALLSELECTED('Table'),[Time] in VALUES('Table'[Time]) && [Date ] in VALUES('Table'[Date ]) && [Measure1]=_max))
var _f=CALCULATE(SUM('Table'[Value 2]),FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] = _b))
RETURN IF(ISINSCOPE('Table'[Time])=FALSE(),_f,_a)
(2) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @LLP515 ,
Thanks bhanu_gautam for the quick reply. I have some other thoughts to add:
(1)We can create measures.
Measure1 = CALCULATE(SUM('Table'[Value 1]),FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] in VALUES('Table'[Time])))
Value1 =
var _a=CALCULATE(SUM('Table'[Value 1]),FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] in VALUES('Table'[Time])))
var _b=MAXX(FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] in VALUES('Table'[Time])),[Measure1])
var _c=IF(ISINSCOPE('Table'[Time])=FALSE(),_b,_a)
RETURN _c
Value2 =
var _a=SUM('Table'[Value 2])
var _max=MAXX(FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] in VALUES('Table'[Time])),[Measure1])
var _b=CALCULATE(MAX('Table'[Time]),FILTER(ALLSELECTED('Table'),[Time] in VALUES('Table'[Time]) && [Date ] in VALUES('Table'[Date ]) && [Measure1]=_max))
var _f=CALCULATE(SUM('Table'[Value 2]),FILTER(ALLSELECTED('Table'),[Date ] in VALUES('Table'[Date ]) && [Time] = _b))
RETURN IF(ISINSCOPE('Table'[Time])=FALSE(),_f,_a)
(2) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you! @Anonymous
@LLP515 , First create a measure for MAX Value 1
Proud to be a Super User! |
|
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |