Forum Discussion

FZOU's avatar
FZOU
Helper IV
6 years ago

Help with DAX

Hello,

I want to do a dax formula but i didn't figure out how to do it,EXP :

 

I have this table which contain : Product,Month,Percent(percent discount per month),AppliedYear(the year to apply the percent,0=CurrentYear(2020);1=2021;2=2022.....

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I added a whatifparam which contain values from 1 to 30 for the choosen Appliedyear by user(if there is any other better solution i'll take it)

 

the need is : if Product is not empty then we display the product with applied year = paramAppliedyear(choosen by user) if we haven't an appliedyear so we take the first smallest applied else we take the first greatest appliedyear.

to be clear : paramAppliedYear=1;if product not empty we display product with appliedyear =1 else product with appliedyear=0 else Productyear with appliedyear=2..

The PBIX file link on drive : https://drive.google.com/open?id=1J4xlclwiGPX8876UG8iuguAQAfG7BZQW
Thank you 🙂

Spoiler
Spoiler
 

 

Spoiler
 

 

4 Replies

  • FZOU what you mean by product not empty? It is not very clear what refers to product  empty or not empty?

    • FZOU's avatar
      FZOU
      Helper IV

      parry2kthank you for your reply,empty it's mean sometimes we don't have a product but we have the months,percent,appliedyear.

  • v-lionel-msft's avatar
    v-lionel-msft
    Community Support

    Hi FZOU ,

     

    Is this logic?

    When paramAppliedYear = x 
        if products <> blank()
        display products  where appliedyear =x
        else
        display products where appliedyear=x-1 && appliedyear = x+1

     

    Best regards,
    Lionel Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.