Power BI Sum by Category and Month - powerbi

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.

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.

Week Header for a Matrix with Monthly Data in Power BI

There are only 2 tables in my model
Calendar Table: Calendar table in Power BI generated through Power Query.
Events table: I am capturing events throughout the year in an Events table. But the problem is event details are by month, no date but just year and month. I concatenated the year and month and converted them into a date to tie it up with the datekey of the Calendar table.
The expected visual is as below and I am unable to display the weeks as shown below as the data is monthly. I somehow have to merge all the weeks into displaying the values under the month. is this possible?

COUNT number of week with specific value ranges

I have a report that shows me the sales for each department for the current year. This is visualized in a matrix with.
The sales table contains a date column that is linked to a simple calendar table that contains information like week, month, year etc.
Now I would like to count the number of weeks where
Strong = Sales above 500k
Extraordinary = Sales above 750k
Moderate = Sales below 500k
How is this possible by using a DAX Measures?
Hopefully this works without sample data because I right now have just access to my cell phone.

Calculate Profitability in DAX (Power BI)

I have the following dataset:
The extrato_fi table has a list of companies referenced by CNPJ_FUNDO and it's name DENOM_SOCIAL. The Informes Diários table has the date (dd/MM/yyyy) and the VL_TOTAL which means the amount of money the company have in that day.
So, I'd like to calculate the profitability in % and the formula is:
Sum of VL_TOTAL of all dates / VL_TOTAL of the first date
It must be possible to filter by date and/or CNPJ_FUNDO in order to know the profitability of a companies or companies in any date or in an interval of dates (See the filters image below. Ano means Year, Mês means Month)
It must be possible to drill down by year, month or day in any table or graph
How can I achieve that?

Finding Previous year Sales in Power BI with week number

I am trying to find the Previous year sales for the same week in Power BI.I dont have any date column.
I have two table one is FACT Indicators table as shown below:
and one sales table( Fact Sales table):
I want to create one calculated field namely(Sales Previous Year) to show the previous year sales for the same week .
In 'Fact Indicators' table 'PY 52 week flag' filed shows if this week id is Previous year or not.
Week column shows the week number from 1 to 52 weeks .
Week Id shows the unique number per Market key.
'Market_Week Id Key' is the common joining key between FACT Indicators table and Fact Sales table
Please help me to find the formula for calculated field.I dont have the date field in my raw data
Every time you deal with anything related to dates, you will need to add what we call a date dimension. It will save you tons of headaches. Once you have it in you will be able to hook it into the creation of the calculated filed.
you can google power bi or ssas date dimension and find tons of information on it.
Yeah! I guess SQL Technical team can be a tough crowd.... Well! In this case, I would recommend bringing the Year into FactSales Table from Fact Indicator . You have two options here with physical relationship set up between Market Week Id Key in both tables you can build a calc column with
Year = CALCULATE(VALUES(FactIndicators[Year]))
or without relationship use LOOKUPVALUE on WeekId
Year = LOOKUPVALUE(FactIndicators[Year], FactIndicators[WeekId], FactSales[WeekId])
Sales Last Year calc colum :
SalesLastYear =
CALCULATE (
SUM(FactSales[SalesThisYear] ),
TOPN(1,
FILTER(
FactSales,
FactSales[Year] < EARLIER(FactSales[Year])
&& FactSales[Key] < EARLIER(FactSales[Key])
)
)
)