Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Extract specific rows from table based on dynamic slicer selection

I have 3 columns Activity period, fiscal period and gross_profit having monthly data .I have activity period on slicer. Now I want to show gross profit of next two fiscal period months. I am not getting how can I approach it I have tried using dateadd function but not getting expected result also tried using calculate function I am still not getting what is expected, please help me I am new to Power BI community

(note-Gross profit is a measure)

On selecting slicer (Activity period= may 2021)

input:

Activity periodFiscal periodGross profit
may 2021april 2021333
may 2021may 20214303
may 2021june 20213340
may 2021july 2021-1112
may 2021august  2021230

 

output:

Activity periodFiscal period Gross profit
may 2021april 2021 
may 2021may 2021 
may 2021june 2021 3340
may 2021 july 2021-1112
may 2021august  2021 

 

  • Hi, Anonymous 

    You can try the following steps:

    1.create a saperate calculated table

     

    Slicer = DISTINCT('Table'[Fiscal period]) 

     

    2.add a new measure to replace the value of measure[M_Gross profit]

     

    M_result = 
    IF (
        DATEDIFF (
            MAX ( Slicer[Fiscal period] ),
            MAX ( 'Table'[Fiscal period] ),
            MONTH
        )
            IN { 1, 2 },
        [M_Gross profit],
        BLANK ()
    )

     

     

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

3 Replies

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

    Hi, Anonymous 

    You can try the following steps:

    1.create a saperate calculated table

     

    Slicer = DISTINCT('Table'[Fiscal period]) 

     

    2.add a new measure to replace the value of measure[M_Gross profit]

     

    M_result = 
    IF (
        DATEDIFF (
            MAX ( Slicer[Fiscal period] ),
            MAX ( 'Table'[Fiscal period] ),
            MONTH
        )
            IN { 1, 2 },
        [M_Gross profit],
        BLANK ()
    )

     

     

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much for Solving my problem Really apreciated. Keep doing great work for community