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
Anonymous
Not applicable

DAX to change monthly figures in to Weekly? Need the results in a table

Hi all

 

I have been given a quarterly budget with monthly values that I need to change in to weekly, in order to compare against our weekly actual spend.

 

The data looks like so:

 

TeamNovemberDecemberJanuaryFebuary
team 110012014090

 

I have unpivoted in query editor to make this:

 

TeamMonthValue
team 1November100
team 1December120

 

To make a weekly budget I just want to take the monthly figure and divide by 4 - assuming straight line usage across the month.

 

End result should be something like this:

 

TeamWeek EndValues
Team 16/11/202025
Team 113/11/202025
Team 120/11/202025
Team 127/11/202025

 

Can anyone help with some dax / query editor tips?

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Anonymous 

This can also be done in Power Query but here is a DAX solution.

You need a date table with the End of Week days and to specify the year in your initial table. You can then create  a new calculated table. See it all at work in the attached file.

Table2 = 
SELECTCOLUMNS (
    GENERATE (
        Table1,
        VAR auxT_ =
            CALCULATETABLE (
                DISTINCT ( DateT[End of Week] ),
                FILTER (
                    ALL ( DateT[Year], DateT[Month Name], DateT[Date], DateT[End of Week] ),
                    DateT[Year] = Table1[Year] && DateT[Month Name] = Table1[Month] && DateT[Date] = DateT[End of Week]
                )
            )
        RETURN
            ADDCOLUMNS ( auxT_, "res", DIVIDE ( Table1[Value], COUNTROWS ( auxT_ ) ) )
    ),
    "Team", [Team],
    "Week end", [End of Week],
    "Values", [res]
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @Anonymous 

This can also be done in Power Query but here is a DAX solution.

You need a date table with the End of Week days and to specify the year in your initial table. You can then create  a new calculated table. See it all at work in the attached file.

Table2 = 
SELECTCOLUMNS (
    GENERATE (
        Table1,
        VAR auxT_ =
            CALCULATETABLE (
                DISTINCT ( DateT[End of Week] ),
                FILTER (
                    ALL ( DateT[Year], DateT[Month Name], DateT[Date], DateT[End of Week] ),
                    DateT[Year] = Table1[Year] && DateT[Month Name] = Table1[Month] && DateT[Date] = DateT[End of Week]
                )
            )
        RETURN
            ADDCOLUMNS ( auxT_, "res", DIVIDE ( Table1[Value], COUNTROWS ( auxT_ ) ) )
    ),
    "Team", [Team],
    "Week end", [End of Week],
    "Values", [res]
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

amitchandak
Super User
Super User

@Anonymous ,Not excat, but this atricle on similar topic, you need to have week of month if needed

 

#powerbi Distributing/Allocating the Yearly Target(Convert to Daily Target): https://community.powerbi.com/t5/Community-Blog/Distributing-Allocating-the-Yearly-Target-Convert-to-Daily/ba-p/1463290

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.