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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jason435
Helper II
Helper II

Bar Chart with Selected Value Monthly or YTD

I would like my YTD/Monthly slicer to filter a bar chart with each bar showing that day's transactions. 

 

I have a table to select what type of period calculation I want to make on that page with a measure '

Period Selected' that returns 1 to monthly and 2 for YTD. My count measure:
 
Count Transactions =
SWITCH (
[Period Selected],
1, DISTINCTCOUNTNOBLANK(Transactions[ID]) ,
2, CALCULATE ( DISTINCTCOUNTNOBLANK(Transactions[ID]) , DATESYTD ( 'dDate'[Date] ))
)

This works great in a matrix. But if I use a bar chart with dates on the x-axis, it doesn't give me the result I am looking for.
For YTD, each bar is the total YTD transactions when I would like to only show that day's transactions. I would also like the bar chart to show all dates in the YTD period. 
 
The bar chart is also filtered by 2 slicers: select month and select year.
 
many thanks. 
2 REPLIES 2
parry2k
Super User
Super User

@jason435 try this

 

Count Transactions =
SWITCH (
[Period Selected],
1, DISTINCTCOUNTNOBLANK(Transactions[ID]) ,
2, CALCULATE ( DISTINCTCOUNTNOBLANK(Transactions[ID]) ,KEEPFILTER( DATESYTD ( 'dDate'[Date] )) )
)

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



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.

Yes, I had tried that. 

On my page I have a month and a year slicer. The month slicer so all the visuals show only KPI for that month's time period. When I select YTD, they all show YTD information up to the end of the month selected. This is what I want. 

 

But with a bar chart it isn't doing what I would like.

 

When 'Monthly' is selected with the current DAX.
PBIDesktop_2020-06-03_09-49-51.png

 

I would like this when YTD is selected. 

 

PBIDesktop_2020-06-03_09-50-25.png

 

right now this is only possible if I select all the YTD months from the month slicer, Jan to May. I would like this result by selecting the end month the month slicer, and YTD from the period slicer. 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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