Forum Discussion
user01
1 year agoResolver I
Dynamic starting date based on filter for bar chart
I get data via DirectQuery and we publish our report our Power BI app, but I provided some dummy data below. We have Product P sales data starting May 2024. We have Product D and Product E sales data...
- 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.
user01
1 year agoResolver I
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.