Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
gaikwadaa123
Helper II
Helper II

Slicer Selection based on the custom column

Hello, I have one table Name 'Calculations' which has below columns 

gaikwadaa123_0-1611687923157.png

I am using 'Code' column as slicer. 

I have seond table 'DEPLoad' 

gaikwadaa123_1-1611688000916.png

I would like to create the custom column in table Calculations table in such a way that whenever i select code '1', the 'Value' that belongs to the code will get substarcted from the 'Net load' column of the table 'DEPLaod'. whenever i select code '2', the 'Value' that belongs to the code will get substarcted from the 'Net load' column of the table 'DEPLaod'. Same for code 3. Same for the diffrenet combinations of the codes, 1,2  or 2,3 or 1,3 or 1,2,3 

Basically i want to subatstarct the'value' from the Net load based on what code or codes I select on the slicer. 

Can anyone help with the custom code. Really appreciate if you could address the issue based on my table names and columns. 

Thank you. 

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @gaikwadaa123 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Calculations:

b1.png

 

DEPLoad:

b2.png

 

You may create a measure as below.

Result Measure = 
var tab = 
ADDCOLUMNS(
    'Calculations',
    "Re",
    CALCULATE(
        SUM(DEPLoad[Net Load]),
        FILTER(
            ALL(DEPLoad),
            [MeasureDate]=EARLIER('Calculations'[DateTimeSelection])
        )
    )-[Value]
)
return
SUMX(
    tab,
    [Re]
)

 

Result:

b3.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @gaikwadaa123 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Calculations:

b1.png

 

DEPLoad:

b2.png

 

You may create a measure as below.

Result Measure = 
var tab = 
ADDCOLUMNS(
    'Calculations',
    "Re",
    CALCULATE(
        SUM(DEPLoad[Net Load]),
        FILTER(
            ALL(DEPLoad),
            [MeasureDate]=EARLIER('Calculations'[DateTimeSelection])
        )
    )-[Value]
)
return
SUMX(
    tab,
    [Re]
)

 

Result:

b3.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

smpa01
Super User
Super User

@gaikwadaa123 the 'Value' that belongs to the code will get substarcted from the 'Net load' - e.g. what is the Net Load value by Code from DEPLoad table for the rows in  'Calculations' table. How do you intend to train the query to lookup for that info? Can you give some example /.logic?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Jimmy801
Community Champion
Community Champion

Hello @gaikwadaa123 

 

are these two tables have a relationship? What you mean with "select code". You need this in a visual? If yes, you have to go for a measure and not for a new column.

 

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Hi The relationship between the tables is on the date column. "code" column is going to be my slicer. so the slicer will have three codes. by clicking any of them the visulas will change. 

Can you help with the calculated column?

 

Hello @gaikwadaa123 

 

as I wrote already. Its not possible to use a selected value in a new column. So you have to go for a new measure and using SUM(DEPLoad[NetLoad])- SUM(Calculations[Value])

Hope this helps


If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors