Forum Discussion
Show maximum Yearmonth Value selected in the Dropdown.
I am working on Tableau to Power BI Migration. In one of my report I have a dropdown which showing Year Month in tableau. The Yearmonth dropdown by default is showing maximum Yearmonth value of the table. But I want to do similar design in Power BI. To do this task I have created a disconnected table contains a column Yearmonth from my main fact table . After that I have sorted the table in descending order. So that the disconnected value is showing like 202512, 202511,202510 ... 202411 so on. Now I put the yearmonth column from disconnected yearmonth table and put into slicer of Power BI. Next from Visual property I made it dropdown and enable single select as ON. Next I have written a DAX measure referring that if no value is selected then show MAX yearmonth value in the dropdown by default selected. But in this context the slicer is showing default selection of MINIMUM yearmonth value. Please help in this regard how to accomplish this task. This is a stautory requirement of user. So that if table got refreshed and new month is added the latest value suppose 202602 will come first and selected by default.
Hi jishnubhattacha
As per my understanding of your requirement, could you please try the steps below?
1. disconnected table which you have already created .
Disconnected_YearMonth =
DISTINCT(FactTable[YearMonth])
2. Create a 1st measure .
Selected YearMonth =
VAR SelectedYM =
SELECTEDVALUE(Disconnected_YearMonth[YearMonth])
RETURN
IF(
ISBLANK(SelectedYM),
MAX(FactTable[YearMonth]),
SelectedYM
)
3. Third measure.
Total Sales (Selected YM) =
CALCULATE(
SUM(FactTable[Sales]),
FactTable[YearMonth] = [Selected YearMonth]
)
If this answers your questions, kindly accept it as a solution and give kudos.
7 Replies
- mdaatifraza5556Super User
Hi jishnubhattacha
As per my understanding of your requirement, could you please try the steps below?
1. disconnected table which you have already created .
Disconnected_YearMonth =
DISTINCT(FactTable[YearMonth])
2. Create a 1st measure .
Selected YearMonth =
VAR SelectedYM =
SELECTEDVALUE(Disconnected_YearMonth[YearMonth])
RETURN
IF(
ISBLANK(SelectedYM),
MAX(FactTable[YearMonth]),
SelectedYM
)
3. Third measure.
Total Sales (Selected YM) =
CALCULATE(
SUM(FactTable[Sales]),
FactTable[YearMonth] = [Selected YearMonth]
)
If this answers your questions, kindly accept it as a solution and give kudos. - jishnubhattachaHelper I
Thank you for the response. I will implement the snippet and if it is working then I will accept it as a solution but if it not works then I will ask you once again
- v-saisrao-msftCommunity Support
Hi jishnubhattacha,
Have you implemented the solution provided by mdaatifraza5556, and has the issue been resolved or not?
Thank you.
- v-saisrao-msftCommunity Support
Hi jishnubhattacha,
Checking in to see if your issue has been resolved. let us know if you still need any assistance.
Thank you.
- jishnubhattachaHelper I
Yes it is woking but with this option the selected item is also shown in the dropdown but other elements are not showing . like if my dropdown has 202601,202512,202511,202510 .. so on. The according to requirement 202601 will be selected by default in the dropdown. It is happening but other values got removed from the dropdown so it is not satisfying the whole requirement. If yuo need more explanation I can provide you with sample screenshots.
- v-saisrao-msftCommunity Support
Hi jishnubhattacha,
I have attached the repro to your issue. Please check if it resolves your problem. If it doesn't, kindly send a screenshot of your issue.
Thank you.
- v-saisrao-msftCommunity Support
Hi jishnubhattacha,
Checking in to see if your issue has been resolved. let us know if you still need any assistance.
Thank you.