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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ankababu007
Frequent Visitor

Need help with Dax

I have below data set

CustomerSourceSalesAmt
cust-1OMS500
cust-2OMS100
cust-3OMS50
cust-4OMS100
cust-1G5100
cust-2G5200
cust-4G5200
cust-2Onsite300
cust-4Onsite100

 

I have a slicer by  source when I select OMS i should only show cust-1 data as that is the only customer who has only OMS . If we select OMS and G5 then we should show data for cust-1,cust-2,cust-4. based on selection for source we should only display customers that belong to only those sources.

 

This is what the out put I am expecting. Please some one can help in writing a dax for this that will be great

Example-1 
Select OMS
 G5
Result 
cust count1
Sales Amt600
  
Example-2 
Select OMS
 G5
 OnSIte
Result 
cust count2
Sales Amt1000
  
Example-1 
Select OMS
  
Result 
cust count1
Sales Amt50

 

1 ACCEPTED SOLUTION

 

 

Jihwan_Kim_0-1679809547216.png

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

Jihwan_Kim_1-1679718948099.png

 

 

Jihwan_Kim_0-1679718913010.png

 

 

Customer count: = 
VAR _sourcecount =
    COUNTROWS ( DISTINCT ( Source[Source] ) )
VAR _selectedsource =
    DISTINCT ( Source[Source] )
VAR _nonselectedsource =
    EXCEPT ( ALL ( Source[Source] ), _selectedsource )
VAR _customerstable =
    ADDCOLUMNS (
        Data,
        "@sourcecount", COUNTROWS ( FILTER ( Data, Data[Customer] = EARLIER ( Data[Customer] ) ) )
    )
VAR _customerlist =
    SUMMARIZE (
        FILTER ( _customerstable, [@sourcecount] = _sourcecount ),
        Data[Customer]
    )
VAR _exceptcustomerlist =
    SUMMARIZE (
        FILTER ( ALL ( Data ), Data[Source] IN _nonselectedsource ),
        Data[Customer]
    )
VAR _expectedcustomerlist =
    EXCEPT ( _customerlist, _exceptcustomerlist )
RETURN
    COUNTROWS ( _expectedcustomerlist )

 

Customer sales expected result: = 
VAR _sourcecount =
    COUNTROWS ( DISTINCT ( Source[Source] ) )
VAR _selectedsource =
    DISTINCT ( Source[Source] )
VAR _nonselectedsource =
    EXCEPT ( ALL ( Source[Source] ), _selectedsource )
VAR _customerstable =
    ADDCOLUMNS (
        Data,
        "@sourcecount", COUNTROWS ( FILTER ( Data, Data[Customer] = EARLIER ( Data[Customer] ) ) )
    )
VAR _customerlist =
    SUMMARIZE (
        FILTER ( _customerstable, [@sourcecount] = _sourcecount ),
        Data[Customer]
    )
VAR _exceptcustomerlist =
    SUMMARIZE (
        FILTER ( ALL ( Data ), Data[Source] IN _nonselectedsource ),
        Data[Customer]
    )
VAR _expectedcustomerlist =
    EXCEPT ( _customerlist, _exceptcustomerlist )
RETURN
    SUMX (
        FILTER ( Data, Data[Customer] IN _expectedcustomerlist ),
        Data[SalesAmt]
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Please find the url for pbix file.I want to see that data in Matrix..

 

https://drive.google.com/file/d/1pHHGbbo-3eaNA-zB_Lld8QN9H08qS1ZZ/view?usp=sharing

 

 

Jihwan_Kim_0-1679809547216.png

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi Thank you very much for your solution I think when I am displaying in Matrix its not working as intended to.

ankababu007_0-1679722131854.png

In this image if I select OMS and G5 matrix should show cust-1 with OMS value of 500 and G5 value of 100.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.