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 all
plz help me in this
I need dax for dynamic week date select
Expected output:
Solved! Go to Solution.
Hi @sarath_chandra ,
Please try below steps:
1. below is my test table
Table:
3. create three measure with below dax formula
Usage current week =
VAR cur_date =
SELECTEDVALUE ( 'Table'[Week Date] )
VAR cur_pn =
SELECTEDVALUE ( 'Table'[PN] )
VAR _val =
CALCULATE (
MAX ( [Usage Value] ),
'Table'[Week Date] = cur_date
&& 'Table'[PN] = cur_pn
)
RETURN
_val
Usage prior week =
VAR cur_date =
SELECTEDVALUE ( 'Table'[Week Date] )
VAR cur_pn =
SELECTEDVALUE ( 'Table'[PN] )
VAR _val =
CALCULATE (
MAX ( 'Table'[Usage Value] ),
WEEKNUM ( 'Table'[Week Date] )
= WEEKNUM ( cur_date ) - 1
&& 'Table'[PN] = cur_pn
)
RETURN
_val
Difference = [Usage current week]-[Usage prior week]
3. add a slicer with "Table[Week Date]" field, add a table visual with field 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 @sarath_chandra ,
Please try below steps:
1. below is my test table
Table:
3. create three measure with below dax formula
Usage current week =
VAR cur_date =
SELECTEDVALUE ( 'Table'[Week Date] )
VAR cur_pn =
SELECTEDVALUE ( 'Table'[PN] )
VAR _val =
CALCULATE (
MAX ( [Usage Value] ),
'Table'[Week Date] = cur_date
&& 'Table'[PN] = cur_pn
)
RETURN
_val
Usage prior week =
VAR cur_date =
SELECTEDVALUE ( 'Table'[Week Date] )
VAR cur_pn =
SELECTEDVALUE ( 'Table'[PN] )
VAR _val =
CALCULATE (
MAX ( 'Table'[Usage Value] ),
WEEKNUM ( 'Table'[Week Date] )
= WEEKNUM ( cur_date ) - 1
&& 'Table'[PN] = cur_pn
)
RETURN
_val
Difference = [Usage current week]-[Usage prior week]
3. add a slicer with "Table[Week Date]" field, add a table visual with field 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.
there @Syndicate_Admin
not sure if i fully get you, you may try to plot the expected table with measures like this:
UsageCurrentWeek =
VAR _date = MAX(TableName[week date])
SUMX(
FILTER(TableName, TableName[week date] = _date ),
TableName[usage value]
)
UsagePriorWeek =
VAR _date = MAX(TableName[week date])
SUMX(
FILTER(TableName, WEEKNUM(TableName[week date]) = WEEKNUM(_date) -1 ),
TableName[usage value]
)
difference = UsageCurrentWeek - UsagePriorWeek
p.s. please consider use English for further post.
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |