Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I have a table in PowerBI (from sharepoint list), includes columns: Name, Status and Date.
Every person has more rows based on their condition in time.
There is no shorting on columns, maybe the Date.
Task:
If I define a reference date, best would be a slicer; then the function is choosing the row pro Name where the date is the closest one to the reference date, but equal or before that.
If one of the chosen row includes "no" Status, then it needs to be hidden, it doesn't matter that the Name has a "yes" Status earlier.
In MS Access I created a frontend and prepared a query with the function above, working well with different reference date, this function should be implemented in powerBI visual table.
Date in mm/dd/yyyy, and 3 examples how it should work:
I hope you can help me
Solved! Go to Solution.
Hi @Quazanic ,
I created a sample pbix file(see the attachment), please check if that is what you want.
1. Create a date dimension table (Please DO NOT create any relationship between the fact table and date dimension table)
2. Create a measure as below
Flag =
VAR _seldate =
SELECTEDVALUE ( 'Date'[Date] )
VAR _seltdate =
SELECTEDVALUE ( 'Table'[Date] )
VAR _selname =
SELECTEDVALUE ( 'Table'[Name] )
VAR _selstatus =
SELECTEDVALUE ( 'Table'[Status] )
VAR _maxdate =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Name] = _selname
&& 'Table'[Date] <= _seldate
)
)
RETURN
IF ( _seltdate = _maxdate && _selstatus = "yes", 1, 0 )
3. Create a visual and apply the visual-level filter on the visual with the condition(Flag is 1)
If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi @Quazanic ,
I created a sample pbix file(see the attachment), please check if that is what you want.
1. Create a date dimension table (Please DO NOT create any relationship between the fact table and date dimension table)
2. Create a measure as below
Flag =
VAR _seldate =
SELECTEDVALUE ( 'Date'[Date] )
VAR _seltdate =
SELECTEDVALUE ( 'Table'[Date] )
VAR _selname =
SELECTEDVALUE ( 'Table'[Name] )
VAR _selstatus =
SELECTEDVALUE ( 'Table'[Status] )
VAR _maxdate =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Name] = _selname
&& 'Table'[Date] <= _seldate
)
)
RETURN
IF ( _seltdate = _maxdate && _selstatus = "yes", 1, 0 )
3. Create a visual and apply the visual-level filter on the visual with the condition(Flag is 1)
If the above one can't help you, please provide some raw data in your table (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Many thanks for your description and the attached file helps a lot.
I create a measure:
Max Date =
CALCULATE(MAXX(FILTER(table, table[Date]), table[Date]), ALL(table[Status]))
In visual table I put Name, Max Date, Status
I can use a slicer, and the table working but there is an interesting failure.
If the closest Date before the Reference Date has "no" Status, then this row is duplicated with a "yes" Staus as well; and what is really strange that this duplicated fake row has same Date what is belong to the "no" Status
How I could eliminate the fake "yes" rows?
User | Count |
---|---|
93 | |
85 | |
78 | |
68 | |
63 |
User | Count |
---|---|
113 | |
99 | |
96 | |
64 | |
58 |