Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi Friends,
I have few blank values for some of the months for some of the names. I want to show previous month value if current month value is blank. so for example in the below snapshot of HOURS SPENT. In March, value for Ankit Gupta is blank, I want to show 9 for March against Ankit Gupta as this is his previous month value.
Below is my backend data:
Please help
Great thanks in advance!
Solved! Go to Solution.
Hi @sandeep_sharma ,
Please try below steps:
1. below is my test table
Table:
2. create a measure with below dax formula
Measure =
VAR cur_name =
SELECTEDVALUE ( 'Table'[Name] )
VAR cur_date =
SELECTEDVALUE ( 'Table'[Date] )
VAR max_date =
MAXX (
FILTER ( ALL ( 'Table' ), 'Table'[Date] < cur_date && 'Table'[Name] = cur_name ),
[Date]
)
VAR _val =
CALCULATE (
MAX ( 'Table'[Hours Spent] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date] = cur_date && 'Table'[Name] = cur_name )
)
VAR _val2 =
CALCULATE (
MAX ( 'Table'[Hours Spent] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date] = max_date && 'Table'[Name] = cur_name )
)
RETURN
IF ( ISBLANK ( _val ), _val2, _val )
3. add a matrix visual with fields and measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thanks for the solution !
I am kind of facing with similar problem. In my case if the if a person does not have any hours recorded against him in any particular month his name is skipped from that month. To encounter the issue I have created two databases. First database contains all the months and second data contains all the names. These two databases are connected to the master sheet. Lets consider the master sheet same as what sandeep_Sharma has provided.
How can i write a DAX to overcome the issue ?
Hi @sandeep_sharma ,
Please try below steps:
1. below is my test table
Table:
2. create a measure with below dax formula
Measure =
VAR cur_name =
SELECTEDVALUE ( 'Table'[Name] )
VAR cur_date =
SELECTEDVALUE ( 'Table'[Date] )
VAR max_date =
MAXX (
FILTER ( ALL ( 'Table' ), 'Table'[Date] < cur_date && 'Table'[Name] = cur_name ),
[Date]
)
VAR _val =
CALCULATE (
MAX ( 'Table'[Hours Spent] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date] = cur_date && 'Table'[Name] = cur_name )
)
VAR _val2 =
CALCULATE (
MAX ( 'Table'[Hours Spent] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date] = max_date && 'Table'[Name] = cur_name )
)
RETURN
IF ( ISBLANK ( _val ), _val2, _val )
3. add a matrix visual with fields and measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Would it be possible to also add the value of April for name B and C. For this case it would have the take the value of last available value which for this case would be Feb value.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
93 | |
75 | |
62 | |
50 |
User | Count |
---|---|
147 | |
107 | |
105 | |
87 | |
61 |