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

Get and use slicer value

Hi Community,

 

As a starter with Power BI, i am trying to create a new table based on another query, which is filtered with a "between dates" slicer. When generating the new table i am not able to get the MIN date with the filters applied.

 

For so far i have used the following working steps:

 

1. Created a new table with a set of dates from 2010 till today

localDates = 
ADDCOLUMNS (
CALENDAR (DATE(2010;1;1); TODAY());
"Format"; FORMAT([Date]; "ddmmyyyy");
"DatumNormalized"; VALUE(FORMAT([Date];"yyyy"))
)

2. Added a slicer and a table to filter and view the dates

 

FilterIssue01.PNG

 

The next thing i am trying to do, is creating a new table based on the filter set for the table "localDates".

I am trying to use the following DAX to achieve this:

localFilteredRevenue = 
VAR minDate = CALCULATE(MIN(localDates[Date]); ALLSELECTED(localDates))
RETURN ADDCOLUMNS(FILTER(cvGlobalRevenue; cvGlobalRevenue[DatumInvoer] > minDate); "CalculatedMinDate"; minDate)

The result of this is that it is creating a new table but this one is not applying the minDate value from the localDates(filtered) table correctly, it is not even calculating the filter, but it shows the smallest value of the other source date:


FilterIssue02.PNG

I hope someone can help me out with this.

 

Thanks!

 

JG

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

Usually, we only need one date table in Power BI. We can make the periods dynamic using the filters, slicers, and measures. 

Can you share a dummy sample and the expected result? Maybe the community can give you a solution.

 

Best Regards,

Community Support Team _ Dale
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

3 REPLIES 3
v-jiascu-msft
Employee
Employee

Hi JG,

 

As we can see from the snapshots and the formula, you did create a calculated table. I'm afraid we can't do it like that. Because the calculated table can't respond to the filters or slicers in the report view. 

What's your goal?

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi v-jiascu-msft,

 

Thanks for your reply!

 

Allright, i am sorry to hear that. My goal is to create multiple datasets, selected on a previous period in time based on the selection made in the slicer. 

 

When for exmaple the slicer selection is equal to the start and end of the current week, month or year, i would like to create datasets with the 3 previous time periods also. I would like to use this to show revenue in equal previous periods, but in different graphs.

 

An ideal situation:

 

localPreviousRevenue =
VAR periodLength = DATEDIFF(localDates[MinDate];localDates[MaxDate];DAY)
VAR minDatePrevious = DATEADD(localDates[MinDate]; (periodLength * -1); DAY)
VAR maxDatePrevious = DATEADD(minDatePrevious; periodLength; DAY)
RETURN FILTER(
    cvGlobalRevenue; 
    cvGlobalRevenue[Date] > minDatePrevious; 
    cvGlobalRevenue[Date] < maxDatePrevious
    )

Best Regards,

Hi @Anonymous,

 

Usually, we only need one date table in Power BI. We can make the periods dynamic using the filters, slicers, and measures. 

Can you share a dummy sample and the expected result? Maybe the community can give you a solution.

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the 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.