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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

SWITCH with 3 conditions based on column gives "random" result

Hi,

Could someone please help, I can't figure out what is the issue with my DAX.

 

I have a "Työaika" table and I'm trying to make calculated column "FTE" but it gives random results. With two statements it works fine both, using switch or if but adding the third condition it gets messed up. for example here is a picture from table and wrong results

hemuli75_0-1655359128236.png

 

My DAX statement:

OsaAika FTE =
SWITCH(True(),
'Työsopimus'[Työsuhteen muoto]="Ei määritetty" && 'Työsopimus'[startdate] <= TODAY() || 'Työsopimus'[enddate] >= TODAY() || BLANK(),0,
'Työsopimus'[Työsuhteen muoto]="Kokoaikainen" && 'Työsopimus'[startdate] <= TODAY() || 'Työsopimus'[enddate] >= TODAY() || BLANK(),1,
'Työsopimus'[Työsuhteen muoto]="Osa-aikainen" && 'Työsopimus'[startdate] <= TODAY() || 'Työsopimus'[enddate] >= TODAY() || BLANK(),
CALCULATE(
SUMX('Työsopimus','Työsopimus'[weeklyworktimemaxminutes])/2/37.5
)
)
4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Your formula involves multiple AND()/OR() conditions. In order to ensure the correctness of the formula, can you describe the logic?

Also, please show the expected result (what is the correct result where you marked) so that we can understand your logic.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Anonymous
Not applicable

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

Please try this:-

OsaAika FTE =
SWITCH (
    TRUE (),
    (
        'Työsopimus'[Työsuhteen muoto] = "Ei määritetty"
            && 'Työsopimus'[startdate] <= TODAY ()
    )
        || ( 'Työsopimus'[enddate] >= TODAY () )
        || ( BLANK () ), 0,
    (
        'Työsopimus'[Työsuhteen muoto] = "Kokoaikainen"
            && 'Työsopimus'[startdate] <= TODAY ()
    )
        || ( 'Työsopimus'[enddate] >= TODAY () )
        || ( BLANK () ), 1,
    (
        'Työsopimus'[Työsuhteen muoto] = "Osa-aikainen"
            && 'Työsopimus'[startdate] <= TODAY ()
    )
        || ( 'Työsopimus'[enddate] >= TODAY () )
        || ( BLANK () ),
        CALCULATE (
            SUMX ( 'Työsopimus', 'Työsopimus'[weeklyworktimemaxminutes] ) / 2 / 37.5
        )
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Hi @Samarth_18 and thank you for your reply. This didn't help. It gives the same result. To mention, I have tried this to other column too and the end result is the same.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.