Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Each if in DAX?

Hi, 

 

I have a table with percentages, and I want to add another table with only five values: 

>5% 

2<x<5 % 

(-2)<x< 2 % 

(-5)<x<(-2) % 

<(-5)%

 

How can I do this in Power BI Desktop? 

(One of the columns the percentages are based on is from another table. 

 

I tried something like this: 

Diff = IF(AND('AssessDataForEachProduct-AllApp'[Vektdiff]<2,'AssessDataForEachProduct-AllApp'[Vektdiff]>-2),"-2<x<2",IF(AND('AssessDataForEachProduct-AllApp'[Vektdiff]>2,'AssessDataForEachProduct-AllApp'[Vektdiff]<5),"+2%",IF(AND('AssessDataForEachProduct-AllApp'[Vektdiff]<-2,'AssessDataForEachProduct-AllApp'[Vektdiff]<-5),"-2%",IF('AssessDataForEachProduct-AllApp'[Vektdiff]>5,5,IF('AssessDataForEachProduct-AllApp'[Vekt]<-5,-5,0)))))
 
... which didn't work.

 

 

Thanks, 

Sigrid 

  • Hi,

    I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

    Please check the below picture and the attached pbix file.

    I hope the below can provide some ideas on how to create a solution for your datamodel.

    It is for creating a new column.

     

     

     

     

     

    Category CC =
    SUMMARIZE (
        FILTER (
            Category,
            Category[Min] < Data[Vektdiff]
                && Category[Max] >= Data[Vektdiff]
        ),
        Category[Category]
    )
    

     

2 Replies

  • Hi,

    I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

    Please check the below picture and the attached pbix file.

    I hope the below can provide some ideas on how to create a solution for your datamodel.

    It is for creating a new column.

     

     

     

     

     

    Category CC =
    SUMMARIZE (
        FILTER (
            Category,
            Category[Min] < Data[Vektdiff]
                && Category[Max] >= Data[Vektdiff]
        ),
        Category[Category]
    )
    

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Wow, that was perfect!! Thank you so much! You totally made my morning! =D