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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community 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])

 

co1.jpg

 

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")))

 

co2.jpg

 

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.

View solution in original post

2 REPLIES 2
v-zhenbw-msft
Community Support
Community 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])

 

co1.jpg

 

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")))

 

co2.jpg

 

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.

amitchandak
Super User
Super User

@Anonymous , You need to two period tables. One can be connected. And then refer this blog. Here I have used the date range. You can use period value. In place on Min and Max and use only Max.  And filter = max value

 

https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.