Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I need to plot a top 5 bar chart. Although the user can select multiple dates, but the bar chart will only show values for the latest date.
For example, my data is:
The date column will be a slicer. If user select only one date, then plot the top 5 values for that date. But if user select two or more dates, the bar chart will only plot the top 5 values for the latest date selected.
Examples:
- If user select "31-Mar-19" only: Plot A(310) C(280) D(7) E(30) F(25)
- If user select "31-Jan-19" and "31-Mar-19": Plot A(310) C(280) D(7) E(30) F(25), as "31-Mar-19" is the latest date selected
- If user select "31-Jan-19" and "28-Feb-19": Plot Plot A(160) C(300) D(70) E(80) F(40), as "28-Feb-19" is the latest date selected.
Thanks
Solved! Go to Solution.
@Anonymous Try following measure, I break down the measures in smaller pieces to easily understand what is going on
Sum of Value = SUM ( 'Top'[Value] ) --get base measure to sum of value
--get sum of most recent date selected
Sum of Latest Date =
VAR __latestDate = MAX ( 'Top'[Date] )
RETURN
CALCULATE (
[Sum of Value],
'Top'[Date] = __latestDate
)
--get sum of top 5
Sum of Top 5 =
VAR __top5 =
TOPN (
5,
ALLSELECTED( 'Top'[Company] ),
[Sum of Latest Date],
DESC
)
RETURN
CALCULATE (
[Sum of Latest Date],
KEEPFILTERS( 'Top'[Company] IN __top5 )
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi,
You may download my PBI file from here.
Hope this helps.
@Anonymous Try following measure, I break down the measures in smaller pieces to easily understand what is going on
Sum of Value = SUM ( 'Top'[Value] ) --get base measure to sum of value
--get sum of most recent date selected
Sum of Latest Date =
VAR __latestDate = MAX ( 'Top'[Date] )
RETURN
CALCULATE (
[Sum of Value],
'Top'[Date] = __latestDate
)
--get sum of top 5
Sum of Top 5 =
VAR __top5 =
TOPN (
5,
ALLSELECTED( 'Top'[Company] ),
[Sum of Latest Date],
DESC
)
RETURN
CALCULATE (
[Sum of Latest Date],
KEEPFILTERS( 'Top'[Company] IN __top5 )
)
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you! The second measure is exactly what I needed!
@Anonymous and here is the output if most recent selected date is Feb 28th
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous missed to mention that you can use bar chart instead of me showing the result in table visual
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
By the way, because I'm already using a top 5 filter to select the top 5 values, I can't add another "Top N" filter for the date. I think what I need is a measure to flag the latest selected date.
Thanks!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
123 | |
78 | |
49 | |
38 | |
37 |
User | Count |
---|---|
196 | |
80 | |
70 | |
51 | |
42 |