<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: IF function that depends on month number in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-function-that-depends-on-month-number/m-p/2150441#M49537</link>
    <description>&lt;P&gt;Hi. I'll help you with the IF statement taking actual/current date regarding the row context of a visualization. I have added comments to help you. It would be a good idea to use variables. You can find your IF with variables and the __better_if that is kind of a better solution for that in case you want to replace it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ROA = 
VAR __current_date = SELECTEDVALUE( Table[Data] ) //Your table example specifies column data as date. This gets the current date in row context
VAR __month = MONTH (__current_date) //if your column is type date you can do this to get the month
VAR __if_condition = 
    IF(__month = 3, 4 
        , IF(__month = 6, 2
            , IF(__month = 9, 1.3333, 1
            )
        )
    )
VAR __better_if = // this would be a better way to handle the if
SWITCH (__month
    , 3, 4
    , 6, 2
    , 9, 1.333
    ,1
)
RETURN
DIVIDE(
    CALCULATE( SUM( UK_DB[Sum, Eur] ), UK_DB[Item] = "Net profit" )
    , CALCULATE( SUM(UK_DB[Sum, Eur]), UK_DB[Item] = "Assets" )
) * __if_condition&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I hope that helps,&lt;/P&gt;</description>
    <pubDate>Fri, 22 Oct 2021 13:10:05 GMT</pubDate>
    <dc:creator>ibarrau</dc:creator>
    <dc:date>2021-10-22T13:10:05Z</dc:date>
    <item>
      <title>IF function that depends on month number</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-function-that-depends-on-month-number/m-p/2149742#M49510</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to calculate Return on assets ratio as annual but don't know how to write IF funcion that depends on month number in table below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ROA = DIVIDE(CALCULATE(SUM(UK_DB[Sum, Eur]),UK_DB[Item]="Net profit"), CALCULATE(SUM(UK_DB[Sum, Eur]),UK_DB[Item]="Assets"))*&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;IF([Date][month]=3;4;IF([Date][month]=6;2;IF([Date][month]=9;1.3333;1)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me with the formula marked in red?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 07:06:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-function-that-depends-on-month-number/m-p/2149742#M49510</guid>
      <dc:creator>Edmundo</dc:creator>
      <dc:date>2021-10-22T07:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: IF function that depends on month number</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-function-that-depends-on-month-number/m-p/2150441#M49537</link>
      <description>&lt;P&gt;Hi. I'll help you with the IF statement taking actual/current date regarding the row context of a visualization. I have added comments to help you. It would be a good idea to use variables. You can find your IF with variables and the __better_if that is kind of a better solution for that in case you want to replace it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ROA = 
VAR __current_date = SELECTEDVALUE( Table[Data] ) //Your table example specifies column data as date. This gets the current date in row context
VAR __month = MONTH (__current_date) //if your column is type date you can do this to get the month
VAR __if_condition = 
    IF(__month = 3, 4 
        , IF(__month = 6, 2
            , IF(__month = 9, 1.3333, 1
            )
        )
    )
VAR __better_if = // this would be a better way to handle the if
SWITCH (__month
    , 3, 4
    , 6, 2
    , 9, 1.333
    ,1
)
RETURN
DIVIDE(
    CALCULATE( SUM( UK_DB[Sum, Eur] ), UK_DB[Item] = "Net profit" )
    , CALCULATE( SUM(UK_DB[Sum, Eur]), UK_DB[Item] = "Assets" )
) * __if_condition&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I hope that helps,&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 13:10:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/IF-function-that-depends-on-month-number/m-p/2150441#M49537</guid>
      <dc:creator>ibarrau</dc:creator>
      <dc:date>2021-10-22T13:10:05Z</dc:date>
    </item>
  </channel>
</rss>

