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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
joshua1990
Post Prodigy
Post Prodigy

Translate Excel Function into Dax

Hello everybody!

Is there any chance to migrate these excel functions into DAX (calculated columns)?

=DATE($A2,1,1)-WEEKDAY(DATE($A2,1,1),3)+(ISOWEEKNUM(DATE($A2,1,1)-WEEKDAY(DATE($A2,1,1),3))<>1)*7
=DATE($A2+1,1,1)-WEEKDAY(DATE($A2+1,1,1),3)+(ISOWEEKNUM(DATE($A2+1,1,1)-WEEKDAY(DATE($A2+1,1,1),3))<>1)*7-1
=ISOWEEKNUM($C2)

In Cell A2 there is a year number.

 

I have already figured out that ISOWEEKNUM is in Dax WEEKNUM with type 21, right?

5 REPLIES 5

You can use "what if" variable instead of "A2" Excel reference.

But what if worked only on measures; not on calculated column and i beleive it will do the job for you.

 

Here are the steps:

1.PNG

2.PNG

3.PNG

 

You can use Year value From Year table now easly.

 

Hope that answers your question.

Best wishes.

 

----------------------------------------------

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

Guys, thanks for your help!

I am just wondering, why I get a different date with Dax compared to the excel Function.

So, I have a calendar with a typical Date column.

This Excel function brings the 29.12.2024 as a result;

=DATE($A2+1,1,1)-WEEKDAY(DATE($A2+1,1,1),3)+(ISOWEEKNUM(DATE($A2+1,1,1)-WEEKDAY(DATE($A2+1,1,1),3))<>1)*7-1

This translated DAX function brings the 05.01.2025 as a result:

=Date(YEAR([Date])+1;1;1)-WEEKDAY(DATE(YEAR([Date])+1;1;1);3)+(WEEKNUM(DATE(YEAR([Date])+1;1;1)-WEEKDAY(DATE(YEAR([Date])+1;1;1);3))<>1)*7-1

Where is my mistake?

 

Edit:

Cell A2 contains year number "2024".

Greg_Deckler
Community Champion
Community Champion

That is correct. WEEKDAY function should operate nearly identically to WEEKDAY in Excel. Same with DATE. What is the question?


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

How can be built that function in Dax?

WEEKDAY(DATE($A2,1,1),3)

 I can't use [Year] as $A2.

How would you replicate this?

So that depends, would need to understand your data layout. 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

 

But in general, you obviously can't use cell references with DAX, you have to filter down to the cell that you want using things like LOOKUPVALUE or MAXX(FILTER(...),...)

 

Things like that.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.