Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Comparison between 2 Categories with Dynamic Slicers

Hello,

 

I am looking for some help with one of the Reports that i am working on.

 

The report basically compares the values in 1 Table between different Periods. Here Period is in Text formt (Example : FY20Q1, FY20Q2,...) The Data sits one below the other and the size of data if around 30 Million rows.

 

I am looking for a help with Data Comparison between different periods and it should give Observations post Comparison. The Observation should in turn be a part of Slicer as well.

 

The data will be as below:

Input:PeriodSA NumberPart NumberPriceQty
 FY20Q1SA1PN10.52
 FY20Q1SA1PN20.43
 FY20Q1SA1PN30.93
 FY20Q1SA1PN40.23
 FY20Q1SA2PN11.21
 FY20Q1SA2PN20.33
 FY20Q2SA1PN10.55
 FY20Q2SA1PN20.42
 FY20Q2SA1PN40.23
 FY20Q2SA1PN50.93
 FY20Q2SA3PN11.21
 FY20Q2SA3PN20.33

 

and the expected Output is as below:

 

      
   FY20Q1FY20Q2 
Output:  QPAQPAObservation
FY20Q1 Vs FY20Q2SA1PN125QPA Increased
  PN232QPA Decreased
  PN33 PN Deleted
  PN433No Change in QPA
  PN5 3PN added
      

 

There should be an option to compare between any selected period (Example : FY20Q1 vs FY20Q2 , FY20Q1 Vs FY20Q4 and so on)

 

Request all the Power BI experts to help me achieve this.

 

Thanks and Regards,

Mohseen

  • Hi Anonymous ,

     

    We can create two slicers based on two new tables and three measures to meet your requirement.

     

    1. Create two new tables just containing the distinct period.

     

    Slicer 1 = DISTINCT('Table'[Period])
    Slicer 2 = DISTINCT('Table'[Period])

     

     

    2. Create three measures and put them to a table visual.

     

    QPA1 = 
    var _selected = SELECTEDVALUE('Slicer 1'[Period 1])
    return
    CALCULATE(SUM('Table'[Qty]),FILTER('Table','Table'[Period]=_selected))

     

    QPA2 = 
    var _selected = SELECTEDVALUE('Slicer 2'[Period 2])
    return
    CALCULATE(SUM('Table'[Qty]),FILTER('Table','Table'[Period]=_selected))

     

    Observation = 
    IF(
        ISBLANK([QPA2]),"PN Deleted",
        IF(
            ISBLANK([QPA1]),"PN added",
            IF(
                [QPA1]<[QPA2],"QPA Increased","QPA Decreased")))

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

    BTW, pbix as attached.

     

    Best regards,

     

    Community Support Team _ zhenbw

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

2 Replies

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    We can create two slicers based on two new tables and three measures to meet your requirement.

     

    1. Create two new tables just containing the distinct period.

     

    Slicer 1 = DISTINCT('Table'[Period])
    Slicer 2 = DISTINCT('Table'[Period])

     

     

    2. Create three measures and put them to a table visual.

     

    QPA1 = 
    var _selected = SELECTEDVALUE('Slicer 1'[Period 1])
    return
    CALCULATE(SUM('Table'[Qty]),FILTER('Table','Table'[Period]=_selected))

     

    QPA2 = 
    var _selected = SELECTEDVALUE('Slicer 2'[Period 2])
    return
    CALCULATE(SUM('Table'[Qty]),FILTER('Table','Table'[Period]=_selected))

     

    Observation = 
    IF(
        ISBLANK([QPA2]),"PN Deleted",
        IF(
            ISBLANK([QPA1]),"PN added",
            IF(
                [QPA1]<[QPA2],"QPA Increased","QPA Decreased")))

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

    BTW, pbix as attached.

     

    Best regards,

     

    Community Support Team _ zhenbw

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