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
lukaspowerbi
Helper II
Helper II

Working with case statement in power bi

I have a query including a case statement(copied below) that run in SQL Server 2012 and I just took it into Power BI. 

My slicer visual (Join Date Range) equals the Case statement from SQL Server:

 

case
when mbr_join_date>=getdate()-7 then 'Last Week'
when mbr_join_date>=getdate()-30 then 'Last Month'
when mbr_join_date>=getdate()-60 then 'Last 60 Days'
when mbr_join_date>=getdate()-90 then 'Last 90 Days'
else 'Last Fiscal Year'

Capture.JPG

 

 

 

 

 

 

 

 

 

 

 

A little bit about data: People are basically joining an organization and as of now the slicer works as a case statament meaning once I choose 'Last Week' Joins I get person A,B and C, however, when I choose 'Last Month' I would expect person A.B,C to be included in the result set but they are not. I know it is because my sql case statement eliminates those. 

 

Can you please advice how can I accomplish person A,B, and C appear in both, 'Last Week' and 'Last Month' and basically in other options too? 

It doesn't matter if the solution is in SQL or power bi as long as it works.

Thank you.

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@lukaspowerbi,

 

Based on your requirements, you could use the relative date slicer.

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

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@lukaspowerbi,

 

Based on your requirements, you could use the relative date slicer.

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

@v-chuncz-msft 

Thank you. Works great.

popov
Resolver III
Resolver III

Hello, @lukaspowerbi
Try this approach I think, is ideal for you case

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.

Top Solution Authors