Forum Discussion

rohtashgoyal's avatar
rohtashgoyal
New Member
4 years ago
Solved

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 di...
  • Anonymous's avatar
    Anonymous
    4 years ago

    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

    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)

    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