Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
elie_abidaher
Helper I
Helper I

Totals for the week

I have a table in SQL containing payments, each payment is having a date. I will filter all the payments by year, then I want to get the totals for every week of that year?

the desired output should be a table with 2 columns

date_of_week         total_payments

4 REPLIES 4

Hi @elie_abidaher ,


is your problem solved?
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Hi @mwegener 

Unfortunatly i didn't manage to get it to work.

the solutions provided will create a table with all the dates in a year, i just want the start and end date of every week in that year, or even just the start date of the week, then i can calculate my total payments for that week

Hi @elie_abidaher ,

 

create a simple date table.

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

DATE =
VAR MINYEAR = YEAR ( MIN ( payments[date] ) )
VAR MAXYEAR = YEAR ( MAX ( payments[date] ) )
RETURN
ADDCOLUMNS (
    FILTER (
        CALENDARAUTO( ),
        AND ( YEAR ( [DATE] ) >= MINYEAR, YEAR ( [DATE] ) <= MAXYEAR )
    ),
    "CALENDAR YEAR", "CY " & YEAR ( [DATE] ),
    "MONTH NAME", FORMAT ( [DATE], "MMMM" ),
    "MONTH NUMBER", MONTH ( [DATE] ),
    "WEEKDAY", FORMAT ( [DATE], "DDDD" ),
    "WEEKDAY NUMBER", WEEKDAY( [DATE] ),
    "QUARTER", "Q" & TRUNC ( ( MONTH ( [DATE] ) - 1 ) / 3 ) + 1
)

 

For the total you can use the quick measure "Year-to-date total".

https://docs.microsoft.com/en-us/power-bi/desktop-quick-measures

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


amitchandak
Super User
Super User

In case data is imported in power BI. You can use week start of end date in your date calendar to group data together

Week Start date = DATEADD('Date'[Date],-1*WEEKDAY('Date'[Date])+1,DAY)
Week End date = DATEADD('Date'[Date],7-1*WEEKDAY('Date'[Date]),DAY)

 

If you want to use day of week. You can have weekday column.

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.