March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I'm going to show a meaure values of this year and last year on a bar chart. I created a new measure in PowerBI Desktop with this formula:
The problem is when I use a Time Slicer and select a year, The calculated measure be disapeared and It sounds the last year data getting filter out from the dataset:
I can see the OrderQuantityLY just when more than 1 year is selected:
Any suggestion?
Thanks,
Ali
Solved! Go to Solution.
@AliSharifi Create a clustered column chart
In the Axis - enter CalendarMonth (this should be a field from the DimDate table that represents just the months)
In the Legend - enter CalendarYear (again from the DimDate table the field that represents just the years)
this field CalendarYear should be the same field you use for the Slicer
In the Value - enter this measure OrderQuantity = SUM(FactInternetSales[OrderQuantity])
This will create a chart that will show 12 columns - overall totals for Jan thru Dec for all years
Then select as many years in the slicer as you wish - you will get that many columns for each month
this works with line charts too and you can select any years to compare not just consecutive
I'm glad it is working.
A couple of points.
I've already created a Calendat Table with the following setup:
Date =
ADDCOLUMNS (
CALENDAR (DATE(2000;1;1); DATE(2025;12;31));
"DateAsInteger"; FORMAT ( [Date]; "YYYYMMDD" );
"Year"; YEAR ( [Date] );
"Monthnumber"; FORMAT ( [Date]; "MM" );
"YearMonthnumber"; FORMAT ( [Date]; "YYYY/MM" );
"YearMonthShort"; FORMAT ( [Date]; "YYYY/mmm" );
"MonthNameShort"; FORMAT ( [Date]; "mmm" );
"MonthNameLong"; FORMAT ( [Date]; "mmmm" );
"DayOfWeekNumber"; WEEKDAY ( [Date] );
"DayOfWeek"; FORMAT ( [Date]; "dddd" );
"DayOfWeekShort"; FORMAT ( [Date]; "ddd" );
"Quarter"; "Q" & FORMAT ( [Date]; "Q" );
"YearQuarter"; FORMAT ( [Date]; "YYYY" ) & "/Q" & FORMAT ( [Date]; "Q" ))
So, which are the following steps now? I've got to create a relationship between column "Date" (calendar Table) and the column "CreationDate"?
Which column do I need to put as a Slicer, the one from the calendar Table or "CreationDate"?
@Isra_BI wrote:I've already created a Calendat Table with the following setup:
Date =
ADDCOLUMNS (
CALENDAR (DATE(2000;1;1); DATE(2025;12;31));
"DateAsInteger"; FORMAT ( [Date]; "YYYYMMDD" );
"Year"; YEAR ( [Date] );
"Monthnumber"; FORMAT ( [Date]; "MM" );
"YearMonthnumber"; FORMAT ( [Date]; "YYYY/MM" );
"YearMonthShort"; FORMAT ( [Date]; "YYYY/mmm" );
"MonthNameShort"; FORMAT ( [Date]; "mmm" );
"MonthNameLong"; FORMAT ( [Date]; "mmmm" );
"DayOfWeekNumber"; WEEKDAY ( [Date] );
"DayOfWeek"; FORMAT ( [Date]; "dddd" );
"DayOfWeekShort"; FORMAT ( [Date]; "ddd" );
"Quarter"; "Q" & FORMAT ( [Date]; "Q" );
"YearQuarter"; FORMAT ( [Date]; "YYYY" ) & "/Q" & FORMAT ( [Date]; "Q" ))
So, which are the following steps now? I've got to create a relationship between column "Date" (calendar Table) and the column "CreationDate"?
Which column do I need to put as a Slicer, the one from the calendar Table or "CreationDate"?
Date =
ADDCOLUMNS (
CALENDAR (DATE(2013,1,1), DATE(2015,12,31)),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", FORMAT ( [Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "Q" & FORMAT ( [Date], "Q" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" )
)
Yes, create the relationship as you say. From then on, only ever use date column from your calendar table (you can hide the other one to avoid confusion). Then write the formula I posted earlier (use the correct name of your calendar table).
Hi @MAllington
Have tried to replicate your year on year bar chart, with the only difference that my data is structured as a single sheet (one column = date of sale, the other column = sales amount).
I created "Total Sales", "Total Sales LY" a new column for "month". I can create a bar chart like the one here with 'total sales' and 'total sales LY', but when making the month by month chart, 'total sales LY' is blank.
Do you have any ideas?
Thank you.
do you have a calendar table? That is the first place to start
http://exceleratorbi.com.au/power-pivot-calendar-tables/
@greggyb is there any documentation about the need to create the join on the date key?
I used the date fields to join and now can see the diffrence as Matt mentioned, In my own datawarehouse models I use date data type for datekey as it just takes 3 bytes instead of 4 bytes for int, so this should be fine for me. But i I think this is a kind of lack of functionality when you can't use the inetegers for joinning.
I'm glad it is working.
A couple of points.
@MattAllington, not sure about documentation. This was actually pointed out to me by another forum member when I suggested someone mark their date table (I'm all hung up on Tabular - that's about the only thing we do development in at my company). This behavior is not replicated in any of the PP for Excel Tabular engines, nor in Tabular itself that I can recall seeing.
It may be a bug, or it may be a result of some new feature / functionality being developed. It is not a major concern for me, as we almost never use the built in time intelligence features. There are so many fiscal calendars at clients, and also bumping up against the edges of what the built-ins can handle. It's easier to just use the FILTER( ALL() ) pattern for everything and not have to remember two sets of edge cases, or two idioms of time intelligence. Also, the logic of FILTER( ALL() ) can be applied to logic on other dimensions; the built-ins have no use outside of DimDate.
As to what the purpose of 'Mark as Date Table' is, why we still need to name the date field in built-in TI functions, and some random stuff on the topic, here are some thoughts:
The issue is that you have the relationship on the Date Key and you are using FullDateAlternateKey in the formula. Change the formula to refer to DateKey
DateKey and OrderDateKey are integer that have data like 20070822. There is nothing wrong with them.
I can't help from here unless you post the workbook.
Sorry Matt, What do you mean of Workbook? do you mean the PowerBI Desktop file?
Yes, that's what I mean - sorry, it's an Excel hangover.
So how about posting the workbook
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |