I do not get my revenue filtered date wise in Power BI - filter

I am a newbie in Power BI. I have created my data model with a Calendar Lookup table which consists of all dates since 2015 to current date and also a Sales table. I have sales entries for 2017 in Sales table. Now I want my Total Revenue gets filtered for a particular date. Suppose the date is 1/1/2017. And I have minimum 6 entries on that Order Date in Sales Table. The calculation I have done to get Total Revenue is -
Total Revenue =SUMX (Sales, Sales [Order Quantity] * Sales [Retail Price])
And now I want to filter this Total Revenue for 1st January 2017. I have chosen CALCULATE function to do that. I have tried this way -
Revenue on 1/1/2017 = CALCULATE ([Total Revenue],
Calendar [Date] = 1/1/2017)
But I do not get any answer. I have perfect relationship status between Sales and Calendar table. I have made a one-to-many relationships between Date in Calendar table and Order Date in Sales table. I can't understand what I am missing out.

You have to provide your date value as below (YYYY,MM,DD):
Revenue on 1/1/2017 = CALCULATE ([Total Revenue], Calendar [Date] = DATE(2017,01,01))
Hope this helps!!

Related

SUMIFS Between Conditions

I am looking for some help with a SUMIFS formula.
I am trying calculate the revenue between dates for a coupon code, where the coupon code sales are in a separate sheet. I need the between dates to be until that discount code appears in the sheet again.
For example,
If a discount code is promoted on the 25th of January and again on the 30th of January, I need the 25th of January row to show the sales since then until the SAME code is promoted again (eg. between 25th January and between 30th January). The 30th of January row would then show the revenue from that date onwards, until the code appears again in another date row in the future.
This is my formula:
=SUMIFS('Code Revenue Feed'!$E:$E,'Code Revenue Feed'!$C:$C,D2,'Code Revenue Feed'!$A:$A,">=" &$B2)
This formula does not show between dates, only from the date it is promoted but I need to show from that date, until the next date the code appears again.
Here's my dataset (please filter the code column by KATIEHAYES so you can see what I mean):
https://docs.google.com/spreadsheets/d/1kzU6T6a95WPoCDkkMjDmqWkKTDOxA0whn1Zk5kGRbBQ/edit?usp=sharing
For this to work, you need to enter an end date in column C (in my copy of your data, this is in cell C664 of the Posting Details UK sheet) where I have chosen 31-Dec-2022 (as your file is view-only, and because you appear to have a filter active on the Posting Details UK sheet, when I copied your data the last row of data on my sheet is 663)
=SUMIFS('Code Revenue Feed'!$E$3:$E$5180,'Code Revenue Feed'!$C$3:$C$5180,D2,'Code Revenue Feed'!$A$3:$A$5180,">="&C2,'Code Revenue Feed'!$A$3:$A$5180,"<"&INDIRECT("C"&IFNA(match(D2,D3:D$663,0)+ROW(),664)))
the above formula can be entered in cell E2 of your UK sheet, and then copied down. This formula uses the INDIRECT() function to determine the 'until' date - if a match for the current coupon code cannot be found in the remaining rows, then the end date from row 664 is used (you will have to adjust both the 663 and 664 references as you have almost 200 more rows of data).

Power Query - DATEADD fails once current year filter applies

Please help. I don't understand why I have 2 similar data models and one works but the other does not.
I have a fact table with a Calendar Key and data as granular by day by location. I have a calendar dimension table with a Calendar key, each individual date, and month/fiscal year definitions.
Measures are Rev = SUM(FactTable[RevColumn]) then Rev PY = CALCULATE([Rev], DATEADD(CalendarTable[Day_Date], -1, YEAR))
Model 1 in Power BI, when I apply date filters, Rev calculates the total revenue & Rev PY calculates last year's rev for same range. Even if I select all dates that are YTD (which is tedious)
Model 2 in Excel 2016 Power Query, when I apply a year filter, Rev calculates total revenue for YTD in Fiscal Year & Rev PY is blank.
I don't understand what is different and why it would even fail in the first place. Calculate is supposed to override the filter context of the current filters right?
Also: the only "Date" type columns are located in the calendar table so it's not possible for me to select the wrong table.
I ultimately had to ask a professor on Udemy.com. The solution is to mark you calendar dimension table as a "Date Table." Since I'm combining the 2 tables on a whole number field, the time intelligence functions only work when filtering with date columns.
By marking the Calendar table as the Date table, the time intelligence functions know to use any attributes from that table to filter down the date ranges and get and display the appropriate answer.
In Power Pivot view, click the "Design" ribbon, then click the "Date Table" button and the "Set Default" button after that.
This resolved all issues I had.

Calculate Full Period Basing Dates Selected by User on the Date Slicer

We need to create a dashboard with a date slicer and a TimeGranularity slicer.
The date slicer allows the user to choose which every date range they want.
The TimeGranularity slicer has the values like Day, Week, Fiscal Period, and etc.
To make it easier to explain. I reduce the model to only 4 tables: a fact table "FactTable", a date table "DateTable", a dim table "TimeGranularity" with flattened dates for different time granularities like Day, Week, Fiscal Period, a dim table "Location"
The TimeGranularity table connects to DateTable as many to one relationship.
What we need is, when the user select on the date slicer with a date range like 01-Jan-2017 to 05-May-2017 and the Fiscal Period level on the TimeGranularity slicer, the metric [Sales] should be able to pull/calculate the full fiscal periods that 01-Jan-2017 and 05-May-2017 fall in plus the fiscal periods in between.
Our DateTable has all the related columns that might be needed for this, like FiscalPeriodID, FiscalPeriodDays (how many days in each FP), FiscalPeriodDayNumber(day numbering in each FP), FiscalPeriodIndex (numbering of all FPs)
Currently the dax for [Sales} is:
[Sales]=Calculate(sum(FactTable[Sales]), TimeGranularity)
I would love to share the pbix file but don't know how to load it up here....
Thanks a lot in advance!

DAX - YTD with year on columns

Can anybody suggest how to write YTD Sales formula in DAX that can be used (e.g. in Excel Pivot Table) with Year on column, to compare YTD sales over the last few years.
Specifically, my difficulty is in determining "as of date". If I refer to the Date table without removing the filter, then something like LASTNONBLANK('Date'[Date],[SalesAmount]) will give me 12/31 of the corresponding year for prior year's columns. And if I remove the Date filter via ALL() I will get the last available date, thus ignoring filters/slicers a user may have added.
I am fairly new to DAX, and was hoping that this was a common scenario that someone has already solved. But all I am finding are the solutions for YTD comparison with prior year, NOT YTD "trend" over multiple years.
Any feedback is really appreciated!
Vlad
You need to provide more details for me to be specific, but I can guess at your dataset.
Assuming:
table1 with Date, Period, Year and SalesAmount
AND
table2 with Period and Year
AND
No relationships.
Your measures might go like this:
MAX_PERIOD = CALCULATE(MAX(table2[Period]))
MAX_YEAR = CALCULATE(MAX(table2[Year]))
YTD Sales = Calculate(Sum([SalesAmount]), FILTER(table1, table1[Period] <= [MAX_PERIOD] && table2[Year] = [MAX_YEAR]))
And your Pivot Table/Matrix might look like this:
_____________________________
|Filters: |Columns: |
| |table2[Period]|
| | |
|____________|______________|
|Rows: |Values: |
|table2[Year]|[YTD Sales] |
_____________________________

Power BI (DAX): Calculating MoM Variance of a Measure Field

I have measure formula that takes a table and converts it to monthly count of distinct customers:
Active Publishers =
CALCULATE(
DISTINCTCOUNT( 'Net Revenue Data'[Publisher Name] ),
'Net Revenue Data'[Active Month] = 1)
Now, I would like to create a new formula that takes the Month-Over-Month (MoM) variance of this trend, like this:
This is the formula I attempted to get the net monthly change:
Net Change = 'Net Revenue Data'[Active Publishers] -
CALCULATE('Net Revenue Data'[Active Publishers],
PREVIOUSMONTH('Net Revenue Data'[Date (Month)]))
How can I create a measure that takes the monthly variance of the 'DistinctCountActiveMonths' measure?
I created an additional date table to relate to the revenue table's date column:
Date Table =
ADDCOLUMNS(CALENDAR("1/1/2000","12/31/2025"),"DateAsInteger",FORMAT([Date],"YYYYMDD"), "Year",YEAR([Date]), "MonthNumber",FORMAT([Date],"MM"),"YearMonthNumber",FORMAT([Date],"YYYY/MM"),"Ye arMonthShort",FORMAT([Date],"YYYY/mmm"),"MonthNameShort",FORMAT([Date],"mmm"),"MonthNameLong",FORMAT([Date],"mmmm"),"DayOfWeekNumber",WEEKDAY([Date]),"DayOfWeek",FORMAT([Date],"dddd"),"DayOfWeekShort",FORMAT([Date],"dddd"),"Quarter","Q"&FORMAT([Date],"Q"),"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" ))
Now I should be able to relate the two tables to create Month over Month variance.
PREVIOUSMONTH(), like all built-in time intelligence functions in DAX requires a proper date dimension with consecutive, non-repeating dates that span from January 1 of the first year you have data to December 31 of the last year you have data.
I am unsure, looking at the tags on your post whether you are using add-ins to Excel or the Power BI desktop program. If Excel, there is an option in the Power Pivot menu to 'Mark as date table', which you should always do in a Tabular model. If Power BI desktop, this functionality is not yet available, so you must create the relationship between your date dimension and fact table on the date field directly, and not on some surrogate key.
One solution to this problem requires 2 steps:
Create an intermediate calculated column that takes the last month's active publishers:
LM Active Pubs = CALCULATE([Active Pubs],DATEADD('Net Rev 09-14'[Date],-1,MONTH))
Subtract the current months "Active Pubs" from the last month's active publishers:
Change in Active Pubs = [Active Pubs]-[LM Active Pubs]

Resources