Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nitinyadav16
New Member

undefined

Hi All,

I am new to power BI and building a logic to calculate the data. I am using the below formula in new column in a table. I want to control period variable with some slicer/ filter (Currently its 2 which is static and i want to make it dynamic). And to do so i have created a numeric parameter but i am unable to pass the parameter in a formula. I am using direct query. (All the column data is in numbers.)

 
Combination Usage =
VAR Months_since_NIT_Order = [Months since NIT Order]
VAR Months_since_s_s = [Months since self-service]
VAR Period =

RETURN
    IF(
        AND(NOT(ISBLANK(Months_since_s_s)), NOT(ISBLANK(Months_since_NIT_Order))),
        IF(
            Months_since_s_s < Period,
            IF(
                Months_since_NIT_Order < Period,
                "S-S and Orders",
                "Only S-S"
            ),
            IF(
                Months_since_NIT_Order < Period,
                "Only Orders",
                "No NIT usage"
            )
        ),
        IF(
            AND(ISBLANK(Months_since_s_s), ISBLANK(Months_since_NIT_Order)),
            "No NIT usage",
            IF(
                ISBLANK(Months_since_s_s),
                "Only Orders",
                "Only S-S"
            )
        )
    )
2 REPLIES 2
Sahir_Maharaj
Super User
Super User

Hello @nitinyadav16,

 

Can you please try the following:

 

Dynamic Combination Usage = 
VAR Months_since_NIT_Order = [Months since NIT Order]
VAR Months_since_s_s = [Months since self-service]
VAR Period = SELECTEDVALUE('Period Table'[Period], 2)

RETURN
    IF(
        AND(NOT(ISBLANK(Months_since_s_s)), NOT(ISBLANK(Months_since_NIT_Order))),
        IF(
            Months_since_s_s < Period,
            IF(
                Months_since_NIT_Order < Period,
                "S-S and Orders",
                "Only S-S"
            ),
            IF(
                Months_since_NIT_Order < Period,
                "Only Orders",
                "No NIT usage"
            )
        ),
        IF(
            AND(ISBLANK(Months_since_s_s), ISBLANK(Months_since_NIT_Order)),
            "No NIT usage",
            IF(
                ISBLANK(Months_since_s_s),
                "Only Orders",
                "Only S-S"
            )
        )
    )

 


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Thank you so much for your response . After using the above formula i get error in "Dynamic Combination Usage (test) = VAR Months_since_NIT_Order = [Months since NIT Order] VAR Months_since_s_s = [Months since self-service]" and the error message is "The value for 'Months since NZM Order' cannot be determined. Either the column doesn't exist, or there is no current row for this column."

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.