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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
reynold522
Helper II
Helper II

error code in dax

Hi all, 

we have installed a lot of IoT devices in US and EU, I would like to check if 
minimum voltage of devices installed in US insider range: 5V -12V
minimum voltage of devices installed in EU insider range: 5V -9V

if above condition satisfied, then notification should return value 1,

the table visual as result will be like following:

IoT device ID Min VoltageRegionnotification
112211EU0
11338EU1
114515US0
115511US1

 

I have following code

MinVoltageN =
VAR _minV=min(datatable[VOLTAGE])

VAR _showminvoltage =
SWITCH( TRUE(),
VALUES(TRACKSHEET[REGION])="EU"&&_minV<9&&_minV>5,1,
VALUES(TRACKSHEET[REGION])="US"&&_minV<12&&_minV>5,1,
BLANK()
)

  -- Notification
VAR _Notificationminvol =
      if (_showminvoltage, 1,0)
    RETURN

 

I got following Error Message:
MdxScript(Model) (127, 1) Calculation error in measure 'Notification'[MinVoltageN]: A table of multiple values was supplied where a single value was expected.

 

appreciate your help and comment!

 

Thanks in advance!


1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

MinVoltageN =
IF (
    ISINSCOPE ( TRACKSHEET[REGION] ),
    VAR _minV =
        MIN ( datatable[VOLTAGE] )
    VAR _showminvoltage =
        SWITCH (
            TRUE (),
            VALUES ( TRACKSHEET[REGION] ) = "EU"
                && _minV < 9
                && _minV > 5, 1,
            VALUES ( TRACKSHEET[REGION] ) = "US"
                && _minV < 12
                && _minV > 5, 1,
            BLANK ()
        ) -- Notification
    VAR _Notificationminvol =
        IF ( _showminvoltage, 1, 0 )
    RETURN
        _Notificationminvol
)

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

Try

MinVoltageN =
IF (
    ISINSCOPE ( TRACKSHEET[REGION] ),
    VAR _minV =
        MIN ( datatable[VOLTAGE] )
    VAR _showminvoltage =
        SWITCH (
            TRUE (),
            VALUES ( TRACKSHEET[REGION] ) = "EU"
                && _minV < 9
                && _minV > 5, 1,
            VALUES ( TRACKSHEET[REGION] ) = "US"
                && _minV < 12
                && _minV > 5, 1,
            BLANK ()
        ) -- Notification
    VAR _Notificationminvol =
        IF ( _showminvoltage, 1, 0 )
    RETURN
        _Notificationminvol
)

Thanks, It works. 

could you help me to understand what could be the problem behid my code?

 

Thanks in advance!

My guess is that the problem was triggered in the total line of a table or matrix value. If the region wasn't filtered down to a single value, as would be the case for a total, then VALUES will return all the regions as a table, and you can't compare a table with multiple rows with a scalar value. By checking ISINSCOPE you are guaranteeing that there will be only 1 value returned and so you can compare that to a scalar value.

thank you very much

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.