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
cahghr
New Member

How to make PARALLELPERIOD function work with filters?

Hi All,

 

Need some urgent help with the following data. 

 

SLS_PERSON_CDSLSMAN_NAMEOOS EventVISIT_DT
111001RichardNo15/Feb/16
111001RichardYes5/Feb/16
111001RichardNo1/Feb/16
111001RichardNo24/Jan/16
111001RichardYes24/Jan/16
111001RichardNo11/Jan/16

 

I need to display the solution in Power BI dashboard as

 

SLS_PERSON_CDSLSMAN_NAMEOOS Count (Current Month)OOS Count (Previous Month)
111001Richard11

 

I need a filter for the month for the dashboard so that if user selects "February", OOS Count should get displayed for January and February both.

 

The formulas used are:

 

OOS Count (Current Month) = TOTALMTD(CALCULATE(COUNTROWS('Distribution by Channel PC'), 'Distribution by Channel PC'[OOS Event] = "Yes"), 'Distribution by Channel PC'[Visit Date] )

 

OOS Count (Previous Month) = CALCULATE(COUNTROWS('Distribution by Channel PC'), 'Distribution by Channel PC'[OOS Event] = "Yes", PARALLELPERIOD('Distribution by Channel PC'[Visit Date], -1, MONTH))

 

ISSUE: The above formulas are giving me correct result but the constraint is in selection of filters. If I select "February" , OOS COUNT (Previous Month) is empty. If I multi-select the filter "January & February", both the columns give me correct result.

 

ASK: Can I display OOS COUNT (Previous Month) by having only "February" as my selection in the filter?

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @cahghr,

 

Perhaps you can try to use below formulas to get the current month count and previous month count.

Calendar table:

Date = VALUES(Sheet1[VISIT_DT])

Measure to get selected value:

Select = IF(HASONEVALUE('Date'[VISIT_DT]),VALUES('Date'[VISIT_DT]),BLANK()) 

 

 

CountEvent(Current) = CALCULATE(COUNT(Sheet1[OOS Event]),FILTER(ALLSELECTED(Sheet1),FORMAT([VISIT_DT],"mm/yyyy")=FORMAT([Select],"mm/yyyy")&&[OOS Event]="Yes"))

CountEvent(Previous) = 
CALCULATE(COUNT(Sheet1[OOS Event]),FILTER(ALLSELECTED(Sheet1),FORMAT([VISIT_DT],"mm/yyyy")=FORMAT(DATE(YEAR([Select]),MONTH([Select]),1)-1,"mm/yyyy")&&[OOS Event]="Yes"))

 

5.PNG6.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @cahghr,

 

Perhaps you can try to use below formulas to get the current month count and previous month count.

Calendar table:

Date = VALUES(Sheet1[VISIT_DT])

Measure to get selected value:

Select = IF(HASONEVALUE('Date'[VISIT_DT]),VALUES('Date'[VISIT_DT]),BLANK()) 

 

 

CountEvent(Current) = CALCULATE(COUNT(Sheet1[OOS Event]),FILTER(ALLSELECTED(Sheet1),FORMAT([VISIT_DT],"mm/yyyy")=FORMAT([Select],"mm/yyyy")&&[OOS Event]="Yes"))

CountEvent(Previous) = 
CALCULATE(COUNT(Sheet1[OOS Event]),FILTER(ALLSELECTED(Sheet1),FORMAT([VISIT_DT],"mm/yyyy")=FORMAT(DATE(YEAR([Select]),MONTH([Select]),1)-1,"mm/yyyy")&&[OOS Event]="Yes"))

 

5.PNG6.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.

Top Solution Authors