Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamically update Pie Chart with data from a direct query based on a time slicer

  The data table below is retrived using Direct Query   Pump Activity Table (Active - 1 , Not Active -  0)   Date Pump Number Active / Not Active 01/01/2019 1 1 02/01/2...
  • v-lid-msft's avatar
    v-lid-msft
    6 years ago

    Hi Anonymous ,

     

    If the donut visual should show the distinct number of pumps for each status, we can try to use the following measures:

     

    PumpNumber = 
    SWITCH (
        SELECTEDVALUE ( LegandTable[LegandName] ),
        "Red", SUMX (
            'Pump Number',
            IF (
                CALCULATE (
                    COUNTROWS ( RELATEDTABLE ( 'Pump' ) ),
                    'Pump'[Active / Not Active] = 0
                ) > 0
                    && CALCULATE (
                        MAX ( 'Pump'[Active / Not Active] ),
                        FILTER ( RELATEDTABLE ( 'Pump' ), 'Pump'[Date] = [Today] - 1 )
                    ) = 1,
                1,
                BLANK ()
            )
        ),
        "Green", SUMX (
            'Pump Number',
            IF (
                CALCULATE (
                    COUNTROWS ( RELATEDTABLE ( 'Pump' ) ),
                    'Pump'[Active / Not Active] = 1
                )
                    = CALCULATE ( COUNTROWS ( RELATEDTABLE ( 'Pump' ) ) ),
                1,
                BLANK ()
            )
        ),
        "Yellow", SUMX (
            'Pump Number',
            IF (
                CALCULATE (
                    MAX ( 'Pump'[Active / Not Active] ),
                    FILTER ( RELATEDTABLE ( 'Pump' ), 'Pump'[Date] = [Today] - 1 )
                ) = 0,
                1,
                BLANK ()
            )
        )
    )

     


    Best regards,