The source table has a table with a single amount and a revenue start and revenue end date. I need to graph the amount over the period by day in PowerBI.
For example:
Looking at the second row the total amount is 730 but I need to calculate a daily rate and display this each day for the revenue period. So if I had a bar chart for this row I would need to show it as 16 April has 34.76, 17 April has 34.76 and so on until 6 May which is the revenue end date. I've tried using between dates but cant seem to get it working.
You can use Power BI's CALENDAR() function to create a table of dates ranging from the minimum revenue start date to the maximum revenue end date.
Dates = CALENDAR(MIN(BookFees[Revenue Start Date]),MAX(BookFees[Revenue End Date]))
Then you can create a calculated column in the Dates table for the daily revenue.
Daily Revenue = Calculate(SUM(BookFees[RevenueDayAmount]),FILTER(BookFees,BookFees[Revenue Start Date]<=Dates[Date] && BookFees[Revenue End Date]>= Dates[Date]))
Here is the resulting bar chart:
Related
I have a table (we'll just call it MyTable) in PowerBI that includes a Date column. I have created a DateDimension table using CALENDARAUTO() with columns for the Date, Month#, MonthName, etc and created the relationship between that Date and the Date in MyTable.
I want to calculate the average year based on the records in MyTable. For example, if I have records with 1/1/2005, 1/1/2014, and 1/1/2015, the average year should be 2011.
How would I go about doing that? I've tried doing a measure of AVERAGE(DateDimension[Year]) and adding that to a Card visual, but it just shows 2.01K. If I do FORMAT(AVERAGE(DateDimension[Year]), "####"), the average is completely wrong.
Since you already have this DateDimension table, use
Average =
AVERAGEX(
MyTable,
RELATED(DateDimension[Year])
)
You can control the formatting by clicking on the measure (Average) and then using the Measure tools pane:
Set it to Whole number and no thousands operator.
I have a measure that calculates shortage dates of a column of items. How do I create a column/measure that outputs a 1-5 ranking based off how closely the shortage date of those items is with the current date. So a 10 would be the closest shortage dates. 5 = within one month, 4 = within two months, ... etc.
I have a Power BI/DAX question. I'm looking to summarize my data by getting monthly transaction sums (including the year as well, i.e. MM/YY) and filtering them by individual account numbers. Here is an example:
I want to take that and make it into this:
I converted the dates to the format I want with this code:
Transaction Month = MONTH(Table[Date]) & "/" & YEAR(Table[Date])
Then got the total monthly sum:
Total Monthly Sum = CALCULATE(sum(Table[Transaction Amount]),ALLEXCEPT(Table, Table[Transaction Month]))
Now I'm trying to figure out how to filter the total monthly sum by individual account numbers. Just as a note - I need this to be a calculated column as well because I'll want to identify accounts that surpass individual account monthly spending limits. Can anyone help me with this?
Thanks so much!
When working with calendar dates, it pays to have a calendar table linked to the transaction table. In the calendar table you will have each date, from the start date of your relevant time period to the end of the time period relevant to your data. The columns of the calendar table can then contain calculations on that date like month number, month name, year, year-month key, transaction month (as the first day of the month for the date in that row), etc.
Next, connect the two tables in the data model by dragging the transaction date to the calendar date column.
Now you can build charts and report tables that group data by month without writing any complicated DAX. Just pull the field "transaction month" from the calendar table and the Total Sum measure from the transaction table into the field well of the visual.
That's what Power BI is all about.
I'm trying to create a table which shows a sum of monthly values for one year compared to the last year's totals (structured as the screenshot below):
Monthly Comparison
However, the caveat I'm dealing with is comparing the most current month, which will always contain partial month data (unless it's the last day of the month), to the same date range of the previous year. In the screenshot I attached, our data for January 2018 only goes through January 22nd. However, it's comparing it to the full month of January from 2017, whereas we want that total to be January 1st - 22nd, 2017: Value That Needs to be Updated.
I've tried messing around with various MTD and cumulative totals, but I can't seem to get the logic to work while keeping the aggregation to the monthly level. Any idea what type of logic needs to used in order to compare year-over-year totals, but only do a partial sum for the same date range of a month that is currently in progress?
Thanks in advance.
In my short example, this seems to work:
Total Sales LY 2 =
VAR MaxDate = EDATE(CALCULATE(MAX(Sales[Date]);ALL(Sales));-12)
RETURN
CALCULATE(
[Total Sales];
FILTER(SAMEPERIODLASTYEAR('Date'[Date]);'Date'[Date]<=MaxDate)
)
I calculate Total Sales for the same period last year, with the max of the last available sales date this year.
Total Sales LY = Comparing last year full month (wrong)
Total Sales LY 2 = Comparing last year month, with max of last sales date
PBIX file
I have a report on Power BI where data comes from a tabular cube. The DAX expressions are made in the cube. When drilling down in Power BI and comparing results to the original numbers there is a slight difference. Power BI calculates the week figures as monday - sunday, but I want it to show from sunday - saturday
Initial code:
IF(ISBLANK([Revenue]), BLANK(), CALCULATE([Revenue],SAMEPERIODLASTYEAR('Date'[Date]),ALL('Date'[Date])))
The date table in cube contains columns [SortFiscalWeek], [SortFiscalMonth], [SortFiscalYear], [Week Commencing],Fiscal Week Number.
Week Commencing is in accordance to Sunday (being the week commence date) - Saturday.
The sort fiscal columns start as 1 from years ago and end to whichever number it is today based on today's date.
I added Fiscal Week Number as I thought it might be helpful and tried using it as Test New Users LY = IF(ISBLANK([New Users]),BLANK(),CALCULATE([New Users],SAMEPERIODLASTYEAR('Date'[Date]),FILTER(ALL('date'),'Date'[Fiscal Week Number]='Date'[Fiscal Week Number]&&'Date'[YearInt] = 'Date'[YearInt]-1)))
EDIT
In Power BI I am using a Clustered Column Chart with Date Hierarchy in the Axis and Revenue in the Value. On week level it sums the Revenue as Monday-Sunday and not Sunday-Saturday. Hope this clears up some doubt as to how i am using the data in Power BI
Can anyone help?
If I understood well, I had the same problem, I created a calculated column giving me the name of the month, like this:
MonthName = SWITCH(DimDate[Month], 1,"gennaio",2,"febbraio",3,"marzo",4,"aprile",5,"maggio",6,"giugno",7,"luglio",8,"agosto",9,"settembre",10,"ottobre",11,"novembre",12,"dicembre","altro")
then I needed to order the month by month number, so to do this you need to select your calculated column, and then go to the tab Modelling>Sort by column, in this menu you can choose on which field of the table you order the selected field.
Hope that helps.