Search code examples
powerbidax

PowerBI - Get 2 tables from 1 table and subtract them


i have the following data.

Group   Modell  Place COUNT
5         A      T1   1
5         A      T2   1
5         B      T1   1
5         B      T2   2
5         B      T3   2

I want to give the user in PowerBi two different slicers where he can choose the Models he want to compare.

Slicer1 = A
Slicer2 = B

What i now need are the following tables.

Table1

Group   Modell1  Modell2    Place COUNT
5         A         B        T1    0
5         A         B        T2   -1
5         A         B        T3   -2

Table2

Group   Modell1  Modell2    COUNT
5         A         B       -3

Hope someone can help. I tried it with parameters, but i am not able to subtract them.


Solution

  • You can try this

    1. create two tables

      Slicer = DISTINCT('Table'[Model])

      Slicer2 = DISTINCT('Table'[Model])

    2. create measures

      Model1 = SELECTEDVALUE(Slicer[Model])

      Model2 = SELECTEDVALUE(Slicer2[Model])

       MEASURE =
       CALCULATE (
           SUM ( 'Table'[COUNT] ),
           'Table'[Model] = SELECTEDVALUE ( Slicer[Model] )
       )
           - CALCULATE (
               SUM ( 'Table'[COUNT] ),
               'Table'[Model] = SELECTEDVALUE ( Slicer2[Model] )
           )
      

    enter image description here