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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
reynold522
Helper II
Helper II

Modified code not working

Hi all, 

I have following code, it works at the moment.

DoDoverboundaryN =

IF (
    ISINSCOPE(TRACKSHEET[IoT_ID_NUMBER]),

CALCULATE (
IF ( VALUES(TRACKSHEET[Capacitythreshold])> ABS ([Max DoD] ), 0, [Max DoD] ),
ALL ( DimDate[Date] )
)
)

Instead returned measure: [Max DoD] in if clause, I would like to change it to a formula:
[Max DoD]/VALUES(TRACKSHEET[Capacitythreshold]

the reuslt will be a measure divide by a column in a table, it sounds weird, however if we put it to a visual table with IoT_ID_NUMBER as first column, then calculation [Max DoD]/VALUES(TRACKSHEET[Capacitythreshold] is only one number
I modified the code as following, the red color is the place modified.
DoDoverboundaryN =

IF (
    ISINSCOPE(TRACKSHEET[IoT_ID_NUMBER]),

CALCULATE (
IF ( VALUES(TRACKSHEET[Capacitythreshold])> ABS ([Max DoD] ), 0[Max DoD]/VALUES(TRACKSHEET[Capacitythreshold] ),
ALL ( DimDate[Date] )
)

the measure wont work anymore, can someone help me in this case?
 
Thanks in advance!

1 ACCEPTED SOLUTION

@reynold522 
Before I start asking you questions, I would like you first try:

DoDoverboundaryN =
IF (
    ISINSCOPE ( TRACKSHEET[IoT_ID_NUMBER] ),
    CALCULATE (
        VAR MaxDoD = [Max DoD]
        VAR Capacitythreshold =
            SUM ( TRACKSHEET[Capacitythreshold] )
        RETURN
            IF (
                Capacitythreshold > ABS ( [Max DoD] ),
                0,
                DIVIDE ( MaxDoD, Capacitythreshold )
            ),
        ALL ( DimDate[Date] )
    )
)

 

View solution in original post

5 REPLIES 5
reynold522
Helper II
Helper II

@v-tangjie-msft  do you have any idea about this?

 

Thanks in advance!

tamerj1
Super User
Super User

Hi @reynold522 

try to use DIVIDE function instead of the / operator 

Thank you I tried this and wrote it in top of my code. it was not working due to measure divide column, 

is it possible to share your suggested code?

Thanks in advance!

@reynold522 
Before I start asking you questions, I would like you first try:

DoDoverboundaryN =
IF (
    ISINSCOPE ( TRACKSHEET[IoT_ID_NUMBER] ),
    CALCULATE (
        VAR MaxDoD = [Max DoD]
        VAR Capacitythreshold =
            SUM ( TRACKSHEET[Capacitythreshold] )
        RETURN
            IF (
                Capacitythreshold > ABS ( [Max DoD] ),
                0,
                DIVIDE ( MaxDoD, Capacitythreshold )
            ),
        ALL ( DimDate[Date] )
    )
)

 

thank you a lot. It works

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.