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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
SagarJagga
Frequent Visitor

replication of elementary P function of Qlik in PowerBI

Hi Team,

I want your help in writing a dax query. My requirement is given below -

My data

 

segementsalesmanufacturer
midsize uv100

A

midsize uv200

B

premium full size400

B

   
   
 

expected sum 300 since ONLY midsize uv is the part of A

 

I want to find out the sum of sales for all those segments where manufacturer is equals to A e.g midsize UV is the part of A manufacturer so total sum of sales would be 100 +200 = 300. premium full size is not part of A so it is ignored

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@SagarJagga ,Please try this formula

 

DAXTotalSalesForSegmentsOfA =
VAR SegmentsOfA =
    CALCULATETABLE(
        VALUES('Table'[segement]),
        'Table'[manufacturer] = "A"
    )
RETURN
    CALCULATE(
        SUM('Table'[sales]),
        'Table'[segement] IN SegmentsOfA
    )
 
I have tried it and it is working attaching PBIX file



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

5 REPLIES 5
bhanu_gautam
Super User
Super User

@SagarJagga ,Please try this formula

 

DAXTotalSalesForSegmentsOfA =
VAR SegmentsOfA =
    CALCULATETABLE(
        VALUES('Table'[segement]),
        'Table'[manufacturer] = "A"
    )
RETURN
    CALCULATE(
        SUM('Table'[sales]),
        'Table'[segement] IN SegmentsOfA
    )
 
I have tried it and it is working attaching PBIX file



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






SagarJagga
Frequent Visitor

Hi Gautam,

Getting an error "A table of multiple values was supplied where a single value was expected"

bhanu_gautam
Super User
Super User

@SagarJagga , You can create a measure for this 

 

SumOfSalesForA =
CALCULATE (
SUM ( YourTable[sales] ),
FILTER (
YourTable,
YourTable[segment] IN {
SELECTCOLUMNS (
FILTER (
YourTable,
YourTable[manufacturer] = "A"
),
"segment", YourTable[segment]
)
}
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks for your help, just wanted to know why selectColumn has not worked.

Much appreciated

 

Hi Gautam,

Actually we have multiple segments which are coming under manufacturer A. so it is throwing an error "A table of multiple values was supplied where a single value was expected"

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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