Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi, I have two Data sets as below.
Table 1:
Product | YTD1 | YTD2 | YTD3 | Total |
A | 10 | 15 | 12 | 37 |
B | 5 | 2 | 1 | 8 |
C | 6 | 1 | 3 | 10 |
Total | 55 |
Table 2:
Month | YTD |
Jan | YTD1 |
Feb | YTD2 |
Mar | YTD3 |
I want to create a NewColumn (or maybe a new measure) in Table 1 which is dependent on a Slicer (value: Jan, Feb, Mar) in the Report.
For example, if filtered value is "Jan" in the slicer, the NewColumn will get YTD1 column, if "Feb", then it will get YTD2 column.
What is the way to do this?
Thank you!
Solved! Go to Solution.
Hi ,
1. Create a table via
Table = union(VALUES(Table2[YTD]),{"NewColumn"})
2. Put the new column [YTD] in 'Table' into Columns of matrix table.
3. Create a mesure use the following code:
Measure =
VAR _sum =
CALCULATE (
SUM ( Table1[Value] ),
'Table1'[YTD] = SELECTEDVALUE ( 'Table'[YTD] )
)
VAR _newcolumn =
CALCULATE (
SUM ( Table1[Value] ),
'Table1'[YTD] = SELECTEDVALUE ( Table2[YTD] )
)
RETURN
IF (
HASONEVALUE ( 'Table'[YTD] ),
IF ( SELECTEDVALUE ( 'Table'[YTD] ) = "newcolumn", _newcolumn, _sum ),
SUM ( Table1[Value] ) + _newcolumn
)
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi ,
1. Create a table via
Table = union(VALUES(Table2[YTD]),{"NewColumn"})
2. Put the new column [YTD] in 'Table' into Columns of matrix table.
3. Create a mesure use the following code:
Measure =
VAR _sum =
CALCULATE (
SUM ( Table1[Value] ),
'Table1'[YTD] = SELECTEDVALUE ( 'Table'[YTD] )
)
VAR _newcolumn =
CALCULATE (
SUM ( Table1[Value] ),
'Table1'[YTD] = SELECTEDVALUE ( Table2[YTD] )
)
RETURN
IF (
HASONEVALUE ( 'Table'[YTD] ),
IF ( SELECTEDVALUE ( 'Table'[YTD] ) = "newcolumn", _newcolumn, _sum ),
SUM ( Table1[Value] ) + _newcolumn
)
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
A slicer choice cannot create a column. It can impact a measure. Read about SELECTEDVALUE() and SWITCH()
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
86 | |
85 | |
84 | |
67 | |
49 |
User | Count |
---|---|
131 | |
111 | |
97 | |
71 | |
67 |