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
skazaryan
Frequent Visitor

Days Group DAX Function

Hi, Can you please help me with DAX formulas, I kinda stuck. 

 

I have START Date and END Date and need to calculate Days Between, I used this function below to create new column:

Days = DATEDIFF([START_DATE],[END_DATE],DAY)
Then I need to group them into categories, this is what I Use to create a new column:
Days Group = if([Days] = 0, "0 Day" , if([Days] = 1, "1 Day", if([Days]  = 2, "2 Days", if([Days] = 3, "3 Days", if([Days] = 4, "4 Days", if([Days] = 5, "5 Days", if([Days] >= 6, "6+ Days", IF(ISBLANK([Days]),BLANK(), "Pending" ))))))))
The problem is, that all my Blank Values capchuring under 0 Days Categorie, insted of Pendings. 
What should I fix in order to get me blanks under "Pendings"?
Also, my new column days is a number type, but if I change it to text then "pending" is working, but my other groups are getting messy. 
 
Please advice. 
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @skazaryan

Please try to create one calculated column as below:

Days Group = IF ( ISBLANK ( [Days] ), "Pending", IF ( [Days] >= 6, "6+", [Days] ) & " Days" )

datediff.JPG

If the above formula is not applicable in your scenario, could you please explain which condition can be grouped as " Pending "?

 

Best Regards

Rena

Community Support Team _ Rena
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

4 REPLIES 4
skazaryan
Frequent Visitor

Thank you, everyone, for the help!

v-yiruan-msft
Community Support
Community Support

Hi @skazaryan

Please try to create one calculated column as below:

Days Group = IF ( ISBLANK ( [Days] ), "Pending", IF ( [Days] >= 6, "6+", [Days] ) & " Days" )

datediff.JPG

If the above formula is not applicable in your scenario, could you please explain which condition can be grouped as " Pending "?

 

Best Regards

Rena

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

Hi @skazaryan 

try to use grouping technique as described here https://docs.microsoft.com/en-us/power-bi/desktop-grouping-and-binning


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
vivran22
Community Champion
Community Champion

Hello @skazaryan 

 

I would recommend to use Power Query for this:

 

Add a custom column:

1.PNG

 

Change the column type to number:

2.png

 

Add a conditional column:

3.PNG

 

Result:

4.PNG

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

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.