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
mcomsto
Helper I
Helper I

Dynamic "Table" based on slicer

Hi,

 

I have the following scenario, but I would like to generate the results based on a slicer for the date range.  Is this possible?  Or is there another way to achieve the results?

 

Scenario:

Patient Table

Patient Activity Table

Filter Patient Activity based on the date range, but show all patients regardless if they have any activities during the date range selected.

 

I would like to have a table visualization in PowerBI with a date range slicer that will allow the user to change the date range, but still return all patients with or without activity during the selected period.

 

This DAX works, but its not dynamic.

PatientsAndActivity = GENERATEALL('Patients',CALCULATETABLE('Patient Activity','Patient Activity'[Activity Completed Date Key] > 20180420, 'Patient Activity'[Activity Completed Date Key] < 20180428))

 

Blank values in the Activity and Activity Completed Date Key columns mean there is no activity for the patient during the designated date range.

 

PHP.Person IDActivityActivity Completed Date Key
1Email20180425
1InPersonMeeting20180426
1PhoneCall20180427
1Email20180427
1PhoneCall20180427
2Email20180425
2PhoneCall20180427
2Email20180427
3  
4PhoneCall20180424
5  
6PhoneCall20180427
7  

 

 

If anyone can help, it will be greatly appreciated.

1 ACCEPTED SOLUTION

Ah, you have just two tables yes? Make a date table. You can do this either by SQL and import like your other tables or make one on the fly:

 

Calendar = ADDCOLUMNS (FIRSTDATE(ACTIVITY_COMPLETED_DATE), LASTDATE(ACTIVITY_COMPLETED_DATE))

 

1. Mark this as a date table and create a relationship to your fact table. Use this as the basis for all your date stuff. It contains every date from the earliest one to the last one in your fact table, even dates for which you have no info.

 

2.  When you build the table visual on a blank page:

 

3. Drag patient names to the table. Check that all patients will be on the table. if not there is a problem with the table formula but from what you posted that sounds unlikely.

 

4. Create a date filter. Change the date and check if the patient names chnage. If they do its a problem with the relationship. Again from what you describe the relationship has been name correctly ie single direction from the patient table to the fact table.

 

5. Drag the activity column into the table visualisation.

 

Good luck.

 

Cheers

 

Sam

 

 

 

 

// If this is a solution please mark as such

 

// if this is a solution please mark as such. Kudos always appreciated.

View solution in original post

6 REPLIES 6
samdthompson
Memorable Member
Memorable Member

So you are wanting all patients to appear in the table even if there is no activity? In that case I would create a patient table with a single directional filter to the fact table, in a simplaitic form it would just be a new table =SUMMARIZE(FACT[PATIENT_NUMBER]). You would then build the table visualisation with the patient number from the Patient table, the activity from the fact table. Just make sure that the relationship to the suppleir table is a single direction.

 

 

 

 

// If this is a solution please mark as such

// if this is a solution please mark as such. Kudos always appreciated.

@samdthompson, thank you for the reply.  I just need a little clarification.

 

You mentioned a supplier table, I assume you are referring to the "new table" i need to create, correct?

 

The relationship you mentioned creating in a single direction, is that a relationship between the "new table" and the patient activity/fact table?

 

matt

@samdthompson,

 

I have tried your suggestion and it is not working.  When I apply the activity fact date slicer not all patient are returned in the table visualization, only patients with activity during the time period.  Any additional ideas?

 

My tables and relationships are:

 

Patient Dim

Patient Activity Fact (M:1 Single with SummarizedPatientFact) and (M:1 Both with Patient Dim)

SummarizePatientFact with Patient ID SummarizePatientFact = SUMMARIZE('Patient Activity Fact','Patient Activity Fact'[Patient ID])

 

Thank you.

Ah, you have just two tables yes? Make a date table. You can do this either by SQL and import like your other tables or make one on the fly:

 

Calendar = ADDCOLUMNS (FIRSTDATE(ACTIVITY_COMPLETED_DATE), LASTDATE(ACTIVITY_COMPLETED_DATE))

 

1. Mark this as a date table and create a relationship to your fact table. Use this as the basis for all your date stuff. It contains every date from the earliest one to the last one in your fact table, even dates for which you have no info.

 

2.  When you build the table visual on a blank page:

 

3. Drag patient names to the table. Check that all patients will be on the table. if not there is a problem with the table formula but from what you posted that sounds unlikely.

 

4. Create a date filter. Change the date and check if the patient names chnage. If they do its a problem with the relationship. Again from what you describe the relationship has been name correctly ie single direction from the patient table to the fact table.

 

5. Drag the activity column into the table visualisation.

 

Good luck.

 

Cheers

 

Sam

 

 

 

 

// If this is a solution please mark as such

 

// if this is a solution please mark as such. Kudos always appreciated.
Ashish_Mathur
Super User
Super User

Hi,

 

Based on that data shared by you, what result are you expecting?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I want the outcome to be what is in the table I added to the post. 

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.