Forum Discussion

Flo95's avatar
Flo95
Frequent Visitor
2 years ago
Solved

IF Function

Hello everyone,

 

i need a Measure for the following Example:

- The "Dunning Level" Column needs to be filled with the measure

- If "Dunning Level 1" >= Todays Date         --> "Dunning Level" should be filled with "Level 1"

- If "Dunning Level 2" >= Todays Date         --> "Dunning Level" should be filled with "Level 2"

- If "Dunning Level 3" >= Todays Date         --> "Dunning Level" should be filled with "Level 3"

- If "Dunning Level 4" >= Todays Date         --> "Dunning Level" should be filled with "Level 4"

 

I already created it in Excel, but I dont know how to do it with a measure in Power Bi (its german language):

 

Many thanks for your help!

 

Kind regards,

Florian

  • I solved the problem with the following code:

    Dunning Level =
    SWITCH(
            TRUE(),
            TODAY() >= [Dunning Level 4], "Level 4",
            TODAY() >= [Dunning Level 3], "Level 3",
            TODAY() >= [Dunning Level 2], "Level 2",
            TODAY() >= [Dunning Level 1], "Level 1",
            "N/A"
        )

5 Replies

  • az38's avatar
    az38
    Community Champion

    Hi Flo95 

    I would suggest you need a calculated column, but not a measure

     SWITCH(
    		TRUE(),
    		[Dunning Level 1] >= TODAY(), "Level 1",
    		[Dunning Level 2] >= TODAY(), "Level 2",
    		[Dunning Level 3] >= TODAY(), "Level 3",
    		[Dunning Level 4] >= TODAY(), "Level 4",
    		"N/A"
    	)
    • Flo95's avatar
      Flo95
      Frequent Visitor

      Hi az38 

       

      The columns "Dunning Level 1/2/3/4" were also created by an Measure.

      Is it still possible to do a calculated column then?

      Im pretty new working with Power BI

       

      Many thanks for your response!

       

      Kind regards,

      Florian

       

      • az38's avatar
        az38
        Community Champion

        Flo95 

        Yes, measures within measures should also work

  • Flo95's avatar
    Flo95
    Frequent Visitor

    I solved the problem with the following code:

    Dunning Level =
    SWITCH(
            TRUE(),
            TODAY() >= [Dunning Level 4], "Level 4",
            TODAY() >= [Dunning Level 3], "Level 3",
            TODAY() >= [Dunning Level 2], "Level 2",
            TODAY() >= [Dunning Level 1], "Level 1",
            "N/A"
        )