Forum Discussion
Dynamic starting date based on filter for bar chart
- 1 year ago
I re-did my approach. I made one measure to indicate whether or not E or D is selected by counting the E/D rows by using SUMX. Then I wrote another measure based on the first one.
EDRows = SUMX(ALLSELECTED('Table'), IF('Table'[PRODUCT] in {"E", "D"}, 1, 0)) sum_salesx = var _ed = [EDRows2] > 0 var _eddate = IF(_ed, "202409", "202405") return SUMX('Table',IF('Table'[YRMO] >= _eddate, 'Table'[SALES] + 0, BLANK()))I put sum_salesx as the Y-axis in the bar chart and it seems to work fine. And in the X-axis, "Show items with no data" is not selected.
Hi user01 ,
You are right, I missed that part. The formula below should work for all the cases.
Sum_Sales =
var _edselected = IF("E" in ALLSELECTED('Table'[PRODUCT]) || "D" in ALLSELECTED('Table'[PRODUCT]) ,
TRUE(),FALSE())
var _eddate = IF(_edselected, "202409", "202405")
RETURN CALCULATE(SUMX('Table', 'Table'[SALES]), 'Table'[YRMO] >= INT(_eddate)+0)
βHope this solution helps you make the most of Power BI! If it did, click 'Mark as Solution' to help others find the right answers.
π‘Found it helpful? Show some love with kudos π as your support keeps our community thriving!
πLetβs keep building smarter, data-driven solutions together! π [Explore More]
Thanks, but it did not work for me. It's basically what I had before, which does not solve "Notice that Product E has no sales in JAN and FEB and shows up blank on the chart. Yes, this is desired." and "Desired behavior if D (and/or E) is selected, and P is selected, but SEP through DEC are deselected (meaning, when there is no data for D and/or E)" from my main post.