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

Create Dynamic Tables based on slicer from the same data set and compare them

Hi All,

 

I'm trying to create 2 dynamic tables based on a 'From Date' , 'Status' and a 'To Date', 'Status' selection

 

Anantha1_0-1628412577511.png

If someone wants to know, how many people moved from Active to Lapsed from April to June

Anantha1_1-1628412667043.png

A3 and A4  had a status of Lapsed in April while they are Active in April

Is this possible in PowerBI?

 

How can I create 2 slicers from 1 column from the same data set?

How can I create dynamic tables based on slicer values and join them to compare

 

@amitchandak  @Fowmy  @v-eqin-msft  @v-rzhou-msft  @Vera_33  @Jihwan_Kim  @mahoneypat  @ImkeF  @DenisSlav   : Could any of you please help

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Create 2 sets of disconnected tables with unique values for month and status (I've prefixed them "From" and "To"). The model shuld look like this:

model.PNG

 

Next create a measure to use as a filter for the visual as follows:

Filter Contact ID =
VAR fromtable =
    CALCULATETABLE (
        VALUES ( 'Table'[Contact ID] ),
        FILTER (
            'Table',
            'Table'[Month] = SELECTEDVALUE ( 'From Month'[Month] )
                && 'Table'[Status] = SELECTEDVALUE ( 'From Status'[Status] )
        )
    )
VAR totable =
    CALCULATETABLE (
        VALUES ( 'Table'[Contact ID] ),
        FILTER (
            'Table',
            'Table'[Month] = SELECTEDVALUE ( 'To Month'[Month] )
                && 'Table'[Status] = SELECTEDVALUE ( 'To Status'[Status] )
        )
    )
RETURN
    COUNTROWS ( INTERSECT ( fromtable, totable ) )

 

Create measures to identify the filtering for the visual following this structure:

From Month =
SELECTEDVALUE ( 'From Month'[Month] )

 

Finally reate the visual with the Contact ID field form the main table and add the measures for "From" and "To". In the filter pane, add the [Filter contact ID] measure to the filters for the visual and set the value to 1:

result.PNG

 

I've attached the sample PBIX file for you





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

5 REPLIES 5
israelfc92
Regular Visitor

Muchas gracias, tambien me ayudo!

Anonymous
Not applicable

@PaulDBrown  Thank you so much, this is exactly what I was looking for!   Could you please explain what "Filter Contact ID" = 1 does?

The [Filter Contact ID] measure works as follows:

VAR fromtable creates a virtual table which lists the Contact ID values from the main table which fulfill the conditions set by the "From" slicers

VAR totable creates a virtual table which lists the Contact ID values from the main table which fulfill the conditions set by the "to" slicers

 

INTERSECT is a function which returns a virtual table including only the Contact IDs present in both virtual tables created in the VARs

Finally COUNTROWS will return a value of 1 for each row present in the virtual table created by INTERSECT.

 

You can then use this measure in the filters for the visual. By setting the filter value to 1, the visual will only show the Contact IDs from the main table which have been listed by the INTERSECT function (in other words, those which fulfill both the "From" and "To" selections in the slicer).

 

To improve user experience, you can create another filter for the "To Month" slicer to show only the months which are after the month selection made in the "From Month" slicer. To do this, I have included an index column in the slicer tables (which also allow for proper sorting).

index.PNG

 

And use this measure in the filters for the "To Month" slicer, setting the value to 1:

 

 

filter "to month slicer" = IF(MAX('To Month'[Index]) > SELECTEDVALUE('From Month'[Index]), 1)

 

 

 

and you get this:

to month slicer.PNG

As you can see, only the months after the month selected in the "From month" are listed in the "To month" slicer.

 

Hope that helps, and let us know if you need further help.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

@PaulDBrown  Awesome, this really helps..thanks again for the detailed explanation

PaulDBrown
Community Champion
Community Champion

Create 2 sets of disconnected tables with unique values for month and status (I've prefixed them "From" and "To"). The model shuld look like this:

model.PNG

 

Next create a measure to use as a filter for the visual as follows:

Filter Contact ID =
VAR fromtable =
    CALCULATETABLE (
        VALUES ( 'Table'[Contact ID] ),
        FILTER (
            'Table',
            'Table'[Month] = SELECTEDVALUE ( 'From Month'[Month] )
                && 'Table'[Status] = SELECTEDVALUE ( 'From Status'[Status] )
        )
    )
VAR totable =
    CALCULATETABLE (
        VALUES ( 'Table'[Contact ID] ),
        FILTER (
            'Table',
            'Table'[Month] = SELECTEDVALUE ( 'To Month'[Month] )
                && 'Table'[Status] = SELECTEDVALUE ( 'To Status'[Status] )
        )
    )
RETURN
    COUNTROWS ( INTERSECT ( fromtable, totable ) )

 

Create measures to identify the filtering for the visual following this structure:

From Month =
SELECTEDVALUE ( 'From Month'[Month] )

 

Finally reate the visual with the Contact ID field form the main table and add the measures for "From" and "To". In the filter pane, add the [Filter contact ID] measure to the filters for the visual and set the value to 1:

result.PNG

 

I've attached the sample PBIX file for you





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul 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.