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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
collis
Frequent Visitor

Dynamic column based on two conditions (matching)

Hello all

 

This forum helped me get a dynamic column working, counting the number of times a date shows (representing an activity) 😍

 

FreqPerDay_ALL = CALCULATE(count(ActiveDaysCount[DatesActive]),ALLEXCEPT(ActiveDaysCount,ActiveDaysCount[DatesActive]))


Now I need to create a new column specific to each region, counting the date frequency again, but only if "Melbourne" is the Region. I tried an 'if' statement, which resulted in only the Melbourne rows triggering a count. However, the result still counted from all rows, so I don't have the filtering right. Can you assist?

So in the FreqPerDay_MELB column, only the rows where Melbourne is listed trigger a count, and the count only includes dates with Melbourne as the region.

 

collis_0-1730872230672.png

 

1 ACCEPTED SOLUTION
collis
Frequent Visitor

I fixed it ... a small change and its working

collis_0-1730879926685.png

 

 

View solution in original post

3 REPLIES 3
collis
Frequent Visitor

I fixed it ... a small change and its working

collis_0-1730879926685.png

 

 

Anonymous
Not applicable

Dear Collis,

To achieve this, you can add a filter specifically for "Melbourne" in your CALCULATE function. This will limit the count to only rows where the region is "Melbourne". You can achieve this by using a filter within the CALCULATE function. Here’s how to modify your formula:

FreqPerDay_MELB =
CALCULATE(
COUNT(ActiveDaysCount[DatesActive]),
ALLEXCEPT(ActiveDaysCount, ActiveDaysCount[DatesActive]),
ActiveDaysCount[Region] = "Melbourne"
)

Note:

The ALLEXCEPT function clears all filters except for the date column, allowing the formula to count all instances of each date, but only within the context of any specified filters, like the region. The filter ActiveDaysCount[Region] = "Melbourne" then ensures that the calculation is restricted to rows where the region is specifically "Melbourne." This setup will make the FreqPerDay_MELB column count only the dates associated with "Melbourne."





Thanks - its not quite working, but nearly there!
Looking at the below. I think it's calculating the correct number of activities on a date in Melbourne e.g. 2 on 1/02/2024, as shown below, but it's listing the two in every row for that date, instead of just the Melbourne lines. The other rows for that date that aren't in Melbourne need to be blank. 

I really appreciate your post.

collis_0-1730878944945.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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