Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello guys,
I am relative new to Power BI and i would really appreciate all the help i can get for what seems as an easy task for all you experts.
I have a table that looks like this:
What i want to do is find the last (according to date) non-blank value and put it in a new column. That value has to be shown in all the rows of the connection_id. So my desired result will have to look like that:
Unfortunately no pbix file is available. I am just looking for the DAX that will allow me to create that new column.
I know you got it guys and you will sure make me look good to my boss!
Thanks in advance
Solved! Go to Solution.
@kostaszogo21 here is my solution, I am sure there are more efficient ways which I will be happy to learn from my fellow experts / super users. I have also attached the sample pbix file for your reference.
LastNonBlankValue =
VAR MaxNonBlankDateForConnection =
CALCULATE (
MAX ( SampleData[date] ),
FILTER (
SampleData,
SampleData[value] <> ""
&& NOT ( ISBLANK ( SampleData[value] ) )
&& SampleData[connection_id] = EARLIER ( SampleData[connection_id] )
)
)
RETURN
CALCULATE (
MAX ( SampleData[value] ),
FILTER (
SampleData,
SampleData[connection_id] = earlier(SampleData[connection_id])
&& SampleData[date] = MaxNonBlankDateForConnection
)
)
Last non-blank value =
VAR _id = 'Table'[connection_id]
VAR _last_availble_date =
CALCULATE (
MAX ( 'Table'[date] ),
REMOVEFILTERS ( 'Table' ),
'Table'[connection_id] = _id,
'Table'[value] <> BLANK ()
)
VAR _result =
CALCULATE (
MAX ( 'Table'[value] ),
'Table'[date] = _last_availble_date,
'Table'[connection_id] = _id,
REMOVEFILTERS ()
)
RETURN
_result
Last non-blank value =
VAR _id = 'Table'[connection_id]
VAR _last_availble_date =
CALCULATE (
MAX ( 'Table'[date] ),
REMOVEFILTERS ( 'Table' ),
'Table'[connection_id] = _id,
'Table'[value] <> BLANK ()
)
VAR _result =
CALCULATE (
MAX ( 'Table'[value] ),
'Table'[date] = _last_availble_date,
'Table'[connection_id] = _id,
REMOVEFILTERS ()
)
RETURN
_result
It works as well! Thanks SpartaBI
@kostaszogo21 here is my solution, I am sure there are more efficient ways which I will be happy to learn from my fellow experts / super users. I have also attached the sample pbix file for your reference.
LastNonBlankValue =
VAR MaxNonBlankDateForConnection =
CALCULATE (
MAX ( SampleData[date] ),
FILTER (
SampleData,
SampleData[value] <> ""
&& NOT ( ISBLANK ( SampleData[value] ) )
&& SampleData[connection_id] = EARLIER ( SampleData[connection_id] )
)
)
RETURN
CALCULATE (
MAX ( SampleData[value] ),
FILTER (
SampleData,
SampleData[connection_id] = earlier(SampleData[connection_id])
&& SampleData[date] = MaxNonBlankDateForConnection
)
)
Thanks so much Moiz!!!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
144 | |
87 | |
65 | |
50 | |
45 |
User | Count |
---|---|
217 | |
88 | |
81 | |
65 | |
56 |