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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
rohtashgoyal
New Member

Need to create a visual equivalent to minus in SQL

I want to achieve below using power bi visual, but don't want to write any raw sql, is that possible?

for example for attendance I want to show list of students who attended class on Jan 3rd, but did't attend on Jan ist.

roll_table has 3 fields only id, name, date, same table records daily rolls for all dates.

so I write

Select  id , name from attendance where date='2022-01-03'

Minus

Select  id , name from attendance where date='2022-01-01'

so it will give me list of students I want.

How to achieve this in Power bi.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rohtashgoyal ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. 

1. Create two date dimension tables and apply the date field on the date slicers

yingyinr_0-1655448828233.png

2. Create a measure as below 

Flag = 
VAR _date1 =
    SELECTEDVALUE('Attend on'[Date])
VAR _date2 =
    SELECTEDVALUE('Not attend on'[Date])
VAR _tab1 =
    CALCULATETABLE (
        VALUES ( 'Table'[name] ),
        FILTER ( 'Table', 'Table'[date] = _date1 )
    )
VAR _tab2 =
    CALCULATETABLE (
        VALUES ( 'Table'[name] ),
        FILTER ( 'Table', 'Table'[date] = _date2 )
    )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[name] ) IN EXCEPT ( _tab1, _tab2 ), 1, 0 )

3. Create a visual and apply a visual-level filter with the condition(Flag is 1)

yingyinr_1-1655448995419.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @rohtashgoyal ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. 

1. Create two date dimension tables and apply the date field on the date slicers

yingyinr_0-1655448828233.png

2. Create a measure as below 

Flag = 
VAR _date1 =
    SELECTEDVALUE('Attend on'[Date])
VAR _date2 =
    SELECTEDVALUE('Not attend on'[Date])
VAR _tab1 =
    CALCULATETABLE (
        VALUES ( 'Table'[name] ),
        FILTER ( 'Table', 'Table'[date] = _date1 )
    )
VAR _tab2 =
    CALCULATETABLE (
        VALUES ( 'Table'[name] ),
        FILTER ( 'Table', 'Table'[date] = _date2 )
    )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[name] ) IN EXCEPT ( _tab1, _tab2 ), 1, 0 )

3. Create a visual and apply a visual-level filter with the condition(Flag is 1)

yingyinr_1-1655448995419.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

rohtashgoyal
New Member

if will be great if I can have two drop down filtes to select dates, so that users have flexibility.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors