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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ashishd
Advocate I
Advocate I

Dynamic Set operations - Intersection, Union in a visual based on user date selections

Hello friends,

 

I have been struggling to do a very simple operation in PowerBI and seek your help for the same.

I have simplified the use case here with the below data.

ashishd_0-1716130876127.png

Date1: 5/1/2024 
Date2: 5/2/2024
Intersection list: Empty

 

Date1: 5/1/2024 
Date2: 5/3/2024
Intersection list: {A, D}

 

I have to provide the user the ability to select any 2 specific dates and then based on the 2 selected dates, show the common items on those 2 dates (intersection) or show items present only on the first date but missing on the second date, etc. kind of set operation results.

The challenge for a new comer to Power BI from Tableau is that in Tableau there are Date Parameters which can be embedded in the formulas and this kind of report can easily be created which is dynamic and user can select different dates and instantly see the result. But I am unable to do the same in PowerBI.

I tried creating 2 separate date tables from which I created 2 date slicers for user selection. But I am stuck in writing the formula as the Calculated column by definition cannot update at run time by changing the date slicers and I don't know how to make this dynamic date driven formula otherwise in PowerBI.

Please help.

 

Thank you!

Ashish

1 ACCEPTED SOLUTION

Hey @ashishd ,

 

here, you will find your pbix that now contains two measures and a new table: https://tommartens-my.sharepoint.com/:u:/g/personal/tom_minceddata_com/EQd2IMfzWjRAqvPx1pUeNGYBEjo-U...

Please be aware that my approach is using only the date table Date1 that is NOT connected to the "fact" table Sheet1.

The additional table is simple: it provides a "simple" llist of joinjypes, that i use as a slicer. This allows a user to select a join type, currently I have the join tpyes implemented:

  • intersect
  • leftanti (items only available in the first date)
  • rightanti (items only available in the second date)

There is a simple measure "vizAid DateSelection" that shows a text depending on the the number of selected dates.

The not so simple measure "Measure" basically creates two tables containing different sets of items.

Depending of the selected join type one condition of the FILTER function will be activated. This approach is necessary because DAX does not allow that a table or column object can be created in the TRUE or FALSE branch of a conditional statement like IF or SWITCH.

This is how my adaption looks like:

Set operations.gif

Hopefully this provides what you are looking for.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

5 REPLIES 5
ashishd
Advocate I
Advocate I

Thanks a lot @TomMartens - This solves my problem.

Thanks @ThxAlot - This approach has also taught me.

ThxAlot
Super User
Super User

One disconnected date table is enough,

ThxAlot_0-1716148247254.png

ThxAlot_3-1716148547292.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



TomMartens
Super User
Super User

Hey @ashishd ,

 

consider creating a pbix file that contains sample data, but still reflects your semantic model (tables, relationships, calculated clumns, and measures). Upload the pbix to OneDrive, Google Drive, or dropbox and share the link. If you are using a spreadsheet to create the sample data, instead of manual input method, share the spreadsheet as well.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hey @TomMartens ,

 

Please check this shared folder with required files: 
https://drive.google.com/drive/folders/1KQW-EHwtnl74htwmaiuV1NWrL6GeIKZx?usp=sharing

 

Thank you!

Ashish

Hey @ashishd ,

 

here, you will find your pbix that now contains two measures and a new table: https://tommartens-my.sharepoint.com/:u:/g/personal/tom_minceddata_com/EQd2IMfzWjRAqvPx1pUeNGYBEjo-U...

Please be aware that my approach is using only the date table Date1 that is NOT connected to the "fact" table Sheet1.

The additional table is simple: it provides a "simple" llist of joinjypes, that i use as a slicer. This allows a user to select a join type, currently I have the join tpyes implemented:

  • intersect
  • leftanti (items only available in the first date)
  • rightanti (items only available in the second date)

There is a simple measure "vizAid DateSelection" that shows a text depending on the the number of selected dates.

The not so simple measure "Measure" basically creates two tables containing different sets of items.

Depending of the selected join type one condition of the FILTER function will be activated. This approach is necessary because DAX does not allow that a table or column object can be created in the TRUE or FALSE branch of a conditional statement like IF or SWITCH.

This is how my adaption looks like:

Set operations.gif

Hopefully this provides what you are looking for.

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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