Sum over partition by- Power bi - powerbi

I am trying to achieve this using dax.
I have a table with date, month, year and amount.
I want to create a measure which gives me the desired output in power bi.
This desired output only changes every time there is a change in the date, month and year.

Try the following measure :
DesiredOutput = CALCULATE(
SUM('yourTable'[Amount]),
FILTER(ALL('yourTable'),
'yourTable'[Month]=MAX('yourTable'[Month])))

Related

PowerBI - Calculate average year from a date column

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.

Date differences in Power BI- Power Query

Hello Everyone i am trying to get a Days Interval column through getting the differnce between Todays Date and a column Refresh date in Power Query, How do i go about it.
I want to do this in Power Query
= DateTime.Date(DateTime.LocalNow())-[Refresh Date]

seeing sales data by "WEEK' in power bi

Can you help me figure out how to display sales data by "WEEKS" in power BI visuals ? I have a calendar table and the date hierarchy is listed by Year, Quarter, Month and Day with no week option.the visual I'd like to create is the chart at the bottom of the image I have attached Thanks
You need to add in the Week to your calendar.
If your are using DAX there are a number of ways
To show the week number of the year use WEEKNUM
Week No = WEEKNUM(Table1[Date], 2)
For the start of the week in a date format use
Start of Week = 'Calendar'[Date] - WEEKDAY('Calendar'[Date],2) +1
The equivalent functions in Power Query are Date.WeekOfYear and Date.StartOfWeek

power bi date measure card

I have a dashboard that needs to display the beginning of the week, on Monday, of the week that I'm in. So for example, if its 1/7/2020, this card would show 1/6/2020. Here is the code I was trying:
Report Date = CALCULATE(TODAY(), FILTER('Calendar', 'Calendar'[WeekStartDate]))
The column in the Calendar table is Weekstartdate, which is accurate and does show the week of 1/6/2020 with the corresponding dates to it; however, it looks like it won't filter it from today's date.
Any ideas? or advice on what I'm doing wrong?
If what you are looking for is a single date, which gives the week start date based on Today's date, you should create a measure:
WeekStartMeasure = TODAY()-WEEKDAY(Today(),2)+1
If you are creating week start date based on a column, then you should create a column with the following calculation:
WeekStartDate = Table[Date]- WEEKDAY(Table[Date],2)+1
Once you create the measure/column, you can use it in the visualization to get the desired result.
We can calculate this way also
if (
WEEKDAY(TODAY(),1) == 1,
TODAY(),
TODAY() - (WEEKDAY(TODAY(),1) - 1)
)

power bi dax last value over a period

I have this table below. How to get Revenue_MTD in DAX? Revenue_MTD equals to the revenue of the last month of each year. The tables are from Tableau and I am converting these to power bi.
with only years:
If you want to get the revenue of the same month previous year you can add a calculated column with this type of dax expression :
Revenue_MTD = SUM(Revenue),
PARALLELPERIOD(
[Date],
-12,
MONTH)
)
you can have more detail on this link :
https://radacad.com/dateadd-vs-parallelperiod-vs-sameperiodlastyear-dax-time-intelligence-question
This is a standard powerbi measure, it should be fairly easy for you to implement this.
MEASURE = CLOSINGBALANCEYEAR(,[,][,])
.
.
.
MEASURE = CLOSINGBALANCEYEAR(SUM(Revenue), DATE )
As long as you have a Date column with appropriate Date Column it should work.
then create another measure with only SUM(revenue)
What expression are you using for your [Revenue_MTD]? Are you using the built-in DAX function TOTALMTD?