Forum Discussion
Dynamic Measure calculation
Hi team ,
i am learning powerbi dax and i am facing difficulty in designing an approach for this implementation:
i have a table with report date , product, activeflag and amount . When i select a date value from report date which is used as slicer i want to get all the rows displayed in a table visual which are tagged to the selected date + the rows that have date < selected date but with active flag ='Y' . Eg . If i have selected 2 aug in my slicer i should display all records belonging to 2 aug + plus active rows from 1 aug and 31 july + 30 july etc . If i select 1 aug in slicer i should be displaying all rows from 1 aug plus only active rows from 31 july , 30 july etc .
- Anonymous2 years ago
lbendlin , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution:
Hi NMDGA ,I created some data:
Here are the steps you can follow:
When the same columns are used in the slicer and the table visual, then the table visual will change with the values selected by the slicer, and we can create a table of dates with no relationship to work with measure
1. Create calculated table.
Date = CALENDAR( DATE(2024,7,1), DATE(2024,10,31))2. Create measure.
Flag = var _select=SELECTEDVALUE('Date'[Date]) return IF( MAX('Table'[report date])=_select || AND( MAX('Table'[report date])<_select,MAX('Table'[activeflag])="Y"),1,0)3. Place [Flag]in Filters, set is=1, apply filter.
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
2 Replies
- lbendlin
Super User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 - AnonymousNot applicable
lbendlin , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution:
Hi NMDGA ,I created some data:
Here are the steps you can follow:
When the same columns are used in the slicer and the table visual, then the table visual will change with the values selected by the slicer, and we can create a table of dates with no relationship to work with measure
1. Create calculated table.
Date = CALENDAR( DATE(2024,7,1), DATE(2024,10,31))2. Create measure.
Flag = var _select=SELECTEDVALUE('Date'[Date]) return IF( MAX('Table'[report date])=_select || AND( MAX('Table'[report date])<_select,MAX('Table'[activeflag])="Y"),1,0)3. Place [Flag]in Filters, set is=1, apply filter.
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly