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

Continuous Formula

Hi,

 

Is there a formula I can use that can be a continuous if then statement without having to write it all out?

 

So far this is my formula for Jan 1,2014:

 

if(Query1[date opened]="01/01/2014",1,0)
 
Is there a way to say:
 
if(Query1[date opened]="01/01/2014",1,if(Query1[date opened]="01/02/2014",2, if(Query1[date opened]="01/03/2014",3,...)
 
but to have it condensed?
I am trying to do this because I need to label all dates from 2014 to present, and it would be helpful if there was a quick way to do this...
 
Thank you!
Sarah
1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

The simple way is use RANKX Function to create a calculate column

Column=RANKX('Date',[Date],,ASC)

 

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

View solution in original post

6 REPLIES 6
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

The simple way is use RANKX Function to create a calculate column

Column=RANKX('Date',[Date],,ASC)

 

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

thank you so so much!
Sarah

Greg_Deckler
Super User
Super User

And maybe this will help:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Sequential/m-p/380231#M116


@ 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...
Greg_Deckler
Super User
Super User

Maybe just DAY([date opened]) ?

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

@Greg_Deckler  this is great! but how do i show it over the years? so 1/1/2014 would be 1, but 1/1/2015 would be 366, 1/1/2016 would be 732 (bc of leap year)

Right, that was the purpose of Sequential, to give a sequential number that spanned years. I think I did it based on weeks and not days but should be relatively easy to modify for days. You may have to scroll through the entire thread because I think there were some bug fixes. I have the official version in my book which I believe had all of the bug fixes and other improvements that I came up with. Let me know if you need some help modifying it. I can probably find some time to go grab my latest code from my book and modify it for day instead of week.


@ 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...

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.