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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
PAVITHRA_R_G
Regular Visitor

Query on slicer

Hello ,

I have a query. Im having a table with patient id, enrolled from date, activated from date and dropped from date . I want a column which calculate the patient status as enrolled, active and dropped. As per the selection the status should change .. for example if I select 2023 Jan to dec if the patient falls under enrolled from to activation before date then the patient is enrolled. Likewise the status should change but also I need a slicer which have patient status which should change according the date n other filter selections. Can anyone please help me to solve this 

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

Hi  @PAVITHRA_R_G ,

 

Here are the steps you can follow:

1. Create calculated table.

Date =
CALENDAR(
    DATE(2023,1,1),
    DATE(2024,12,31))

vyangliumsft_0-1723179853047.png

2. Enter data – create a group table.

vyangliumsft_1-1723179853048.png

3. Create measure.

Measure =
var _mindate=MINX(ALLSELECTED('Date'),'Date'[Date])
var _maxdate=MAXX(ALLSELECTED('Date'),'Date'[Date])
var _column=
SELECTCOLUMNS(FILTER(ALL('Date'),'Date'[Date]>=_mindate&&'Date'[Date]<=_maxdate),"test",[Date])
return
SWITCH(
    TRUE(),
MAX('Table'[Activated from]) in _column && MAX('Table'[Dropped from]) in _column,"dropped",
MAX('Table'[Enrolled from]) in _column && MAX('Table'[Activated from]) in _column,"active",
MAX('Table'[Enrolled from]) = MAX('Table'[Activated from]) ,"active")
Measure 2 =
COUNTX(
    FILTER(ALL('Table'),
    [Measure]=MAX('Group_Table'[Group])),[Person ID])

4. Result:

vyangliumsft_3-1723179931566.png

 

 

Best Regards,

Liu Yang

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
v-yangliu-msft
Community Support
Community Support

Hi  @PAVITHRA_R_G ,

 

Here are the steps you can follow:

1. Create calculated table.

Date =
CALENDAR(
    DATE(2023,1,1),
    DATE(2024,12,31))

vyangliumsft_0-1723179853047.png

2. Enter data – create a group table.

vyangliumsft_1-1723179853048.png

3. Create measure.

Measure =
var _mindate=MINX(ALLSELECTED('Date'),'Date'[Date])
var _maxdate=MAXX(ALLSELECTED('Date'),'Date'[Date])
var _column=
SELECTCOLUMNS(FILTER(ALL('Date'),'Date'[Date]>=_mindate&&'Date'[Date]<=_maxdate),"test",[Date])
return
SWITCH(
    TRUE(),
MAX('Table'[Activated from]) in _column && MAX('Table'[Dropped from]) in _column,"dropped",
MAX('Table'[Enrolled from]) in _column && MAX('Table'[Activated from]) in _column,"active",
MAX('Table'[Enrolled from]) = MAX('Table'[Activated from]) ,"active")
Measure 2 =
COUNTX(
    FILTER(ALL('Table'),
    [Measure]=MAX('Group_Table'[Group])),[Person ID])

4. Result:

vyangliumsft_3-1723179931566.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

v-yangliu-msft
Community Support
Community Support

@lbendlin , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution:
Hi  @PAVITHRA_R_G ,

I created some data:

vyangliumsft_0-1722825047951.png

Here are the steps you can follow:

Does the statement " if I select 2023 Jan to dec if the patient falls under enrolled from to activation before date then the patient is enrolled " mean that the enrolled date and activated date are before the minimum date selected by the slicer

1. Create calculated table.

Table 2 =
CALENDAR(
    DATE(2023,1,1),DATE(2025,12,31))

vyangliumsft_1-1722825047953.png

2. Create measure.

Measure = 
var _mindate=MINX(ALLSELECTED('Table 2'),'Table 2'[Date])
var _minmonthdate=DATE(YEAR(_mindate),MONTH(_mindate),1)
RETURN
IF(
  MAX('Table'[enrolled from date])<_minmonthdate&&MAX('Table'[activated from date])<_minmonthdate,
    "enrolled")

3. Result:

vyangliumsft_2-1722825078176.png

As far as I know, only calculated columns can be placed on top of the slicer, you need to use Enter data to create a table containing patient status, using [patient status] as the slicer

vyangliumsft_3-1722825225678.png

1. Then create a measure to customize the rules for each status, such as the following:

Test = 
var _mindate=MINX(ALLSELECTED('Table 2'),'Table 2'[Date])
var _minmonthdate=DATE(YEAR(_mindate),MONTH(_mindate),1)
var _status=
SWITCH(
    TRUE(),
    MAX('Table'[enrolled from date])<_minmonthdate&&MAX('Table'[activated from date])<_minmonthdate&&MAX('Table'[dropped from date])<_minmonthdate,"dropped",
    MAX('Table'[enrolled from date])<_minmonthdate&&MAX('Table'[activated from date])<_minmonthdate,
    "enrolled")
return
_status
Flag =
var _test=
SELECTCOLUMNS(
    'Table',"test",[Test])
RETURN
IF(
    MAX('status table'[patient status]) in _test,1,0)

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_4-1722825225679.png

3. Result:

vyangliumsft_5-1722825285894.png

If the above results do not meet your expectations, can you express the expected results in the form of a picture, we can help you better.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Screenshot_2024-08-07-12-32-59-10_87869c5c71fa0655e350912352595c23.jpg

thank you @v-yangliu-msft for your response. This is much useful but my requirement need so more additions. I have send you the full requirement details in that image which I'm attaching with this. Thanks in advance 

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.