The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hey Community
I have a report page showing YTD Costs, with a setup where a single year and month can be chosen, and it benchmarks for the same period last year. In my bar chart, there is only one month displayed when i choose "March", However i want it to show January, February and March in individual bars, and so forth, all the way to december, so that if december is chosen, it displays 12 bars, one for each month of the year. I have limited acces, so i dont have the ability to make tables and edit relationships, and also no parameters. Basically, it has to be done only with measures.
I have tried many solutions, but none that worked, please help!
Hello @BiDevFred,
Can you please try this:
1. Create a measure for the Maximum Month Number
Max Month Number =
MAX('DateTable'[MonthNumber])
2. Filter Bar Chart by Max Month
Filter Months =
VAR CurrentMonth = 'DateTable'[MonthNumber]
RETURN
IF(CurrentMonth <= [Max Month Number], 1, BLANK())
3. Display YTD Costs
YTD Costs =
VAR CurrentMonth = 'DateTable'[MonthNumber]
VAR CurrentYear = MAX('DateTable'[Year])
RETURN
IF([Filter Months] = 1,
CALCULATE(
SUM('DataTable'[Costs]),
FILTER(
ALL('DateTable'),
'DateTable'[Year] = CurrentYear &&
'DateTable'[MonthNumber] <= CurrentMonth
)
),
BLANK()
)
4. Display LYTD (Last Year To Date) Costs
LYTD Costs =
VAR CurrentMonth = 'DateTable'[MonthNumber]
VAR CurrentYear = MAX('DateTable'[Year])
VAR LastYear = CurrentYear - 1
RETURN
IF([Filter Months] = 1,
CALCULATE(
SUM('DataTable'[Costs]),
FILTER(
ALL('DateTable'),
'DateTable'[Year] = LastYear &&
'DateTable'[MonthNumber] <= CurrentMonth
)
),
BLANK()
)
Should you require any further assistance, please do not hesitate to reach out to me.
Hello Sahir, thanks for answering.
Filter Months = VAR CurrentMonth = 'DateTable'[MonthNumber] RETURN IF(CurrentMonth <= [Max Month Number], 1, BLANK())
VAR CurrentMonth = Wont let me choose the datetable, only measures i have created
Sincerely,
User | Count |
---|---|
15 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |