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
mikep7521
Helper III
Helper III

trying to get a the week number of the year for a certain date

 

Hello, Please see pictures attached. You can see in the first picture that I used Column from Example to get the week of the year. The values are right in that column. but when i try to use that same column in a table (picture 2) you can see that the nvalues are not correct. Why is this? I already attempted to do a regular column and I was receiving the same wrong answers.

PBI 2.PNG

1 ACCEPTED SOLUTION
mikep7521
Helper III
Helper III

I figured out the issue. Thanks for everyone's help. There were multiple installments closing on the same date so the weeknum function was totaling all the week numbers together for multiple installments with the same close date.

View solution in original post

18 REPLIES 18
mikep7521
Helper III
Helper III

I figured out the issue. Thanks for everyone's help. There were multiple installments closing on the same date so the weeknum function was totaling all the week numbers together for multiple installments with the same close date.

In picture I attached you can see the very simple formula using the weeknum function. When you look in the table you will see that the outputs are incorrect. Why am I not receiving the correct answer?

WeekNum.PNG

@mikep7521,

 

Which 'Date' are you using for your filter context in your table visual?

 

For instance, in my sample :

 

Column = WEEKNUM(Table1[SubmittedDate],2)

Column 2 = WEEKNUM(Table1[ApprovedDate],2) 

*notice they are taking the WEEKNUM( ) of different dates

 

Produces different numbers based on the filter context:

 

2.PNG

 

 

My guess is that you are not using a proper 'Date' Dimension table that is related to your 'Fact' table thereby giving you unexpected values.






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



I'm trying to find the week number for the Close Date field. The only filter on this table is that the close date is in 2018. What do you mean by using a proper 'Date' Dimension table that is related to the table I'm displaying in the picture I added on my original post? the close date field and the weeknumber field are on the same table so I'm confused on what relationship you are talking about.

@mikep7521,

 

It's a pretty subtle difference that could/can make a pretty huge impact on the expected outcome. I have yet to find a reason to not have a proper 'Date' Dimension table related to my 'Fact' table. The 'Date' table is what I use in the filter context of the visual, not the [Date] or [Weeknum] from the 'Fact' table.

 

Of course, with my sample, I was not able to produce the wildly incorrect numbers that are in your visual. That is why I asked what was the current filter context of the visual was.

 

My suggestion is that you create a date table with the necessary information you need e.g. [Week Ending] etc.

 

Then relate the [Est_Close_Date_c] to the [Date] from the Calendar Table. Use the 'Calendar'[Week Ending] in your visual.

 

 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



I related the [Est_Close_Date_c] to the [Date] from my date Table.  I now have no filters on my table. I'm still receiving the same wrong answers.

Share your data if possible please.






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Hi @mikep7521,

 

It seems that you have solved your problem. Please accept the reply making sense as the solution to your question so that people who may have the same question can get the solution directly.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ChrisMendoza
Resident Rockstar
Resident Rockstar

@mikep7521,

 

Seems like a duplicate post to me. I responded on this post https://community.powerbi.com/t5/Desktop/WEEKNUM-function-isn-t-working/m-p/477951#M222391.

 

@Greg_Deckler might you agree with my opinion?






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Yep, duplicate. @mikep7521, please don't cross post, leads to confusion. Tough to be sure, how are the tables related? Which columns are related? Quite possibly has to do with that relationship. 

 

Overall...Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I only have one relationship established. I pulled my two data tables (Deals & Installments) from Salesforce. They are related to each other via ID field on deal table and Deal Name  field on installment table, this relationship was autodetected by power bi. What relationship would I need to establish in order to make this function work correctly.

So then what columns from what tables are you using in your table visualization?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I'm using estimated close date from the installment table and then trying to create a weeknum column on the installment table as well.

@mikep7521

Are you creating a dax measure or a dax column? Minor difference but might be causing the issue. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Column. When i attempted a measure i got an error code when adding to a visual.

Greg_Deckler
Super User
Super User

Are those two tables linked in some way? Not sure what you are doing there. Can't you just create a DAX calculated column and use WEEKNUM function?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

any suggestions as to why my dax function isn't working? 

Close Date Week Number = WEEKNUM(Close Date,2)

WeekNum.PNG

I only have two tables and yes they are related. I created a column using this formula:

Est. Close Date Week = WEEKNUM(Installment[Est_Close_Date__c],2)

and I'm receiving the same wrong answers as the picture i attached to my original post.

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.