Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I would like to plot a max line in my line chart for all months. It should ignore my slicer for year and always show the max sale amount for each month in the year. Which means if I select only 2024, it should still show max for each month from any year in my table.
I would like it to also be dynamic and show max of selected area and/or industry..
I know I have to make a measure for each year and use a contains etc to have more measures (max and for each year)..
Just trying to think how I can create a max line as well. I've tried using sumarize like this:
Max sales =
VAR tbl = SUMMARIZE(
sheet1,
sheet1[Month],
sheet1[Year],
"Total sales", SUM(sheet1[sale]))
Return
CALCULATE(
MAXX(tbl, [Total sales]),
ALL(sheet1[year])
)
But this is still filtering when i select a year..
Can anyone help me with this?
I've attached a pbix file.
Solved! Go to Solution.
Hi @newbie_but_conf ,
Try the following code:
Max sales = VAR MaxMonth = MAX(sheet1[Month])
VAR tbl =
SUMMARIZE(
FILTER(
ALL(sheet1),
sheet1[Month] = MaxMonth
),
sheet1[Year],
sheet1[Month],
"Total sales", MAX(sheet1[sale])
)
RETURN
MAXX(
CALCULATETABLE(
tbl,
REMOVEFILTERS(sheet1[Year]),
sheet1[Month] = MAX(sheet1[Month])
),
[Total sales]
)
PBIX attached
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @newbie_but_conf ,
Your solution is great, @MFelix . It worked very well! Here's another idea I'd like to share with you for reference.
I worked very hard on this case and there was no solution at that time, so I hope you'll take a look at mine as well.
There are some problems with the data when you use Year directly from the original table.
Create a date table and extract the year and month:
Calendar = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))
Year = YEAR('Calendar'[Date])
Month = MONTH('Calendar'[Date])
Create two measures to calculate Sum of Sales and Monthly Maximum:
Sales =
VAR _Slicer = SELECTEDVALUE('Calendar'[Year])
VAR _currentDate = MAX('Table'[Date])
RETURN
IF(YEAR(MAX('Table'[Date]))=_Slicer,SUM('Table'[Sale]),IF(_Slicer=BLANK(),SUM('Table'[Sale])))
MaxSales =
VAR _currentdate = MAX('Table'[Date])
RETURN
CALCULATE(MAX('Table'[Sale]),FILTER(ALLSELECTED('Table'),'Table'[Date]=_currentdate))
Create the Slicer using the Year of the Calendar table, leaving the other two Slicers unchanged.
Use Line Chart, Year Slicer choose 2024, the page effect is as follows:
On this basis Area Slicer selects 1 and the page effect is as follows:
The pbix file is attached.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi @newbie_but_conf ,
Try the following code:
Max sales = VAR MaxMonth = MAX(sheet1[Month])
VAR tbl =
SUMMARIZE(
FILTER(
ALL(sheet1),
sheet1[Month] = MaxMonth
),
sheet1[Year],
sheet1[Month],
"Total sales", MAX(sheet1[sale])
)
RETURN
MAXX(
CALCULATETABLE(
tbl,
REMOVEFILTERS(sheet1[Year]),
sheet1[Month] = MAX(sheet1[Month])
),
[Total sales]
)
PBIX attached
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsUser | Count |
---|---|
94 | |
86 | |
78 | |
68 | |
63 |
User | Count |
---|---|
113 | |
99 | |
97 | |
64 | |
59 |