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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Dax calculation to filter out values basis on scenarios given in the same table

Hi everyone,
I have a table_1 which has columns ( qty, procurement,week)
so under qty there are values, Under procurement we have different categories (1,2,3,4). Under week we have ( week 1-20)
So I have to create a measure to get a value when,
[( Values from qty which are of 2nd category only and week from 11-16 only (subtract) Values from qty which are of 4th category and week from 11-16 only ( divide) Values from qty which are of 2nd category only and week from 11-16 only ]
Pardon me If I am not conveying it in proper way as I am new to the community and powerbi.
Thanks 
@amitchandak 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Anonymous 

try like:

Measure = 
VAR _value1 =
CALCULATE(
    SUM(TableName[qty]), 
    TableName[Procurement]=2, 
    TableName[week]>=11,
    TableName[week]<=16
)
VAR _value2 =
CALCULATE(
    SUM(TableName[qty]), 
    TableName[Procurement]=4, 
    TableName[week]>=11,
    TableName[week]<=16
)
RETURN
DIVIDE(_value1 - _value2, _value1)

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @Anonymous 

try like:

Measure = 
VAR _value1 =
CALCULATE(
    SUM(TableName[qty]), 
    TableName[Procurement]=2, 
    TableName[week]>=11,
    TableName[week]<=16
)
VAR _value2 =
CALCULATE(
    SUM(TableName[qty]), 
    TableName[Procurement]=4, 
    TableName[week]>=11,
    TableName[week]<=16
)
RETURN
DIVIDE(_value1 - _value2, _value1)

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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