Forum Discussion
Anonymous
6 years agoNot applicable
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...
- 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,
v-lid-msft
6 years agoCommunity Support
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,
Anonymous
6 years agoNot applicable
Hi Dong Li,
Thanks for providing a solution. This is a wonderful way to workaround the limitations of measures and visuals in Power BI.
Thank You
Regards
Avinash