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

Filtering with RELATED fields

Hi

 

I have the following issue. My facts table has two columns, <order date> and <order value>.

 

my calendar table has <date>, and out of the date I have columns for day, month and year. So a typical row looks something like that.

 

<date>,<day>,<month>,<year>

23/12/2019, 23, 12, 2019.

 

The date columnt is the one that join the two tables with a relationship. What I want to do is create a measure, i.e. sum of total sales buy apply a filter not in the related field which is the date field in both tables but on the day field. 

 

for example, I want to calculate the sum of all sales that were booked on the 15th day of any month. I have tried the following and it works fine

 

CALCULATE(SUM([order value]); FILTER (fsales; DAY(RELATED([date]))=15)) 

 

however, I want to be able to filter using the already existing <day> field in the calendar table.  some columns in the calendar table are more complex and I don't want to repeat their calculation in the filter stament in the measure

 

is this possible?

 

thank you

 

 

 

 

 

2 REPLIES 2
Nathaniel_C
Super User
Super User

Hi @Anonymous ,

Total Sales Filtered by Visual (Allselected) = CALCULATE([Total Sales],ALLSELECTED('Calendar'[DayNumberOfMonth]))

-----------------------------

Total Sales by day number = CALCULATE([Total Sales],'Calendar'[DayNumberOfMonth] = 15)

Since as you say the tables are related, you don't actually need FILTER.  The top measure filters on a visual, the bottom measure is perhaps a quicker way to get your measure done.
 
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel 
filter by day.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

@Nathaniel_C  hi, thanks for the reply, apologies for taking so long to reply...

 

I'm not sure I've defined the problem correctly, I can't get what I wanted by the proposed solution. 

 

Suppose that we wanted to generate a matrix that would have the total sales amount for each of the 31 days on any one month. so the table would look something like that:

 

1, 500$

2, 300$

3, 400$

.

.

31, 600$

 

where every row would be the sum of total sales generated on the Xth of any one month.

 

to make it event trickier, assume that there is a 3rd table that has the following rows

DayNo

5,

10

15,

20,

25,

31

 

and we wanted to generate a matrix that would sum the total sales whose day would be <= of any one of the values above. So the table woud look like

 

5, 2000$ (sales from 1st to 5th day of any one month)

10, 3000$ (sales from 6th to 10th day of any one month)

15, (etc...)

20,

25,

31

 

Thank you

 

Chronis

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