To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi,
I can't solve the problem problem:
I have a table in PowerBI:
Month (YYYY-MM)
Year (YYYY)
Client
Sale
I need to create a filter named Trend (increasing, decreasing, steady). Scenario:
User choose the time interval in the filter Year or Month and choose Increasing in the Trend.
Report should choose the Clients with increasing Sale in the chosen time.
Is it possible?
The difficulty is the lack of a standard date table.
I have access to this table in sqlserver so maybe some transformation in the source would helps..
Thank you for the ideas 🙂
Hi @lukzas ,
Thanks to @Shravan133 and @Joe_Barry for their quick replies. Did their replies solve your problem? If so, please mark helpful replies as solutions. If no, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. Thank you.
Best Regards,
Neeko Tang
Hi @lukzas
You can create a date table by following the instructions here. https://learn.microsoft.com/en-us/power-bi/guidance/model-date-tables
When you create the basic Calendar table create a custom column for (YYYY-MM)
Year/Month = FORMAT('Calendar'[Date], "YYYY-MM")
Create a Many to Many Relationship from the new column above to the Month column in your table. Force the relationship so that Calendar filters your table. click on Cross Filter direction and choose the option I mentioned.
How do you want to create a trend, you need something to compare against a KPI? If you can provide some context and a range you want to measure against, we could use a similar measure below to calculate the last 3 months for example and compare it against the KPI
Last 3 months template measure
Last 3 Months =
CALCULATE (
[YourSalesMeasure],
DATESINPERIOD ( 'Calendar'[Date], MAX ( 'DIM Date'[Date] ), -3, MONTH )
)
Joe
Proud to be a Super User! | |
Date tables help! Learn more
Yes, you can achieve this in Power BI, even without a standard date table. Here’s a step-by-step approach to create a filter named "Trend" that allows users to choose "Increasing," "Decreasing," or "Steady" and shows the clients with the corresponding sales trend:
You’ll need to create measures to determine if sales are increasing, decreasing, or steady over the selected time period.
Example Measures:
TotalSales = SUM('YourTable'[Sale])
PreviousPeriodSales =
CALCULATE(
[TotalSales],
DATEADD('YourTable'[Month], -1, MONTH) // For monthly data
// DATEADD('YourTable'[Year], -1, YEAR) // For yearly data
)
SalesTrend =
SWITCH(
TRUE(),
[TotalSales] > [PreviousPeriodSales], "Increasing",
[TotalSales] < [PreviousPeriodSales], "Decreasing",
"Steady"
)
Create a slicer to allow users to select the trend type.
TrendOptions =
DATATABLE(
"Trend", STRING,
{ {"Increasing"}, {"Decreasing"}, {"Steady"} }
)
To filter the data based on the selected trend, you need to apply a visual filter or create a calculated table based on the trend selection.
Using Visual Level Filters:
Using a Calculated Table (Alternative Approach):
You could also create a calculated table that filters clients based on the selected trend.
FilteredClients =
VAR SelectedTrend = SELECTEDVALUE('TrendOptions'[Trend])
RETURN
FILTER(
SUMMARIZE(
'YourTable',
'YourTable'[Client],
"TotalSales", [TotalSales],
"SalesTrend", [SalesTrend]
),
[SalesTrend] = SelectedTrend
)
If you prefer to do transformations in SQL Server, you could pre-calculate some of these metrics and trends in your SQL queries or views to make it easier to work with in Power BI.
thank you, but:
the solution filter only months when it is a increase, but for example :
- 2023-01 increase
- 2023-02 increase
- 2023-03 decrease
- 2023-04 increase
so the overall trend is increasing and if the user choose increasing and time period from 2023-01 to 2023-04 , the report should give those months with the clients (not only 01,02,04)
User | Count |
---|---|
14 | |
11 | |
6 | |
6 | |
5 |
User | Count |
---|---|
29 | |
17 | |
11 | |
7 | |
5 |