Forum Discussion

pimgo's avatar
pimgo
New Member
5 years ago
Solved

If Statement wrong column total (with greater than)

Dear all,

 

I have been searching for the correct solution the whole day, but unfortunately I have not found it yet. When incerting the following DAX code as new measure I get the incorrect colomn total: 

 

 

    IF(
        [Gasketel kWh]>0,
        SUMX(VasteWaarden,[dT]),
        0)

 

 

[Gasketel kWh] is a calculated measure. 

 

I get the measure/column total of VasteWaarden[dT].I have also tried the hasonefilter code, but it does not seem to work (no values): 

 

 

Gasketel draaiuren = IF(HASONEFILTER('VasteWaarden'[dT]),
IF([Gasketel kWh]>0,SUM(VasteWaarden[dT]),0),
SUMX(FILTER('VasteWaarden',[Gasketel kWh]<0),0))

 

 

 

Does anyone know what I should do differently? Many thanks if anyone knows what to do..! 

Regards, Pim

  • Hi, pimgo 

    Thank you for sharing.

    Please check the link down below, that I included the fixed version of two measures.

    I hope I correctly understood your question.

     

    https://www.dropbox.com/s/hzfvlnxo55rc8fj/Uitlegmodel.pbix?dl=0 

     

    Hi, My name is Jihwan Kim.

     

    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

     

    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM

6 Replies

  • Hi, pimgo 

    I am not quite sure whether I understood your question correctly, but try the below for newly creating a column.

     

    new column = 

    IF(
            [Gasketel kWh]>0,
            calculate ( SUM([dT])),
            0)

     

    Hi, My name is Jihwan Kim.

     

    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

     

    Linkedin: https://www.linkedin.com/in/jihwankim1975/

    • pimgo's avatar
      pimgo
      New Member

      Unfortunately when adding a column it doesn't show any values. 

      My problem is a followed: When using the if forumla  I get an incorrect colomn total. Question: I want to get the correct sum from all the individual lines. 

      • Jihwan_Kim's avatar
        Jihwan_Kim
        Icon for Super User rankSuper User

        Hi, pimgo 

        Thank you for your feedback.

        Please try two steps.

         

        First measure = your first created measure

         

        Second measure = sumx (values(vastewaarden[dt]), [first measure])

         

         

         

         

        It is quite difficult for me to tell something without seeing your sample pbix file.

         

        Hi, My name is Jihwan Kim.

         

        If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

         

        Linkedin: https://www.linkedin.com/in/jihwankim1975/