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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
gshaikh
Regular Visitor

Distinct Count with grouping on product and date

Hello,

 

Please help me on creating a measure for distinct count but it shoud be group with product and shippeddate 

here is my sql code for that 

SELECT COUNT(ORDERNO),ShippedDate
,KSCH
FROM
(SELECT SBUCode,
COUNT(ORDERNO) CNT,
OrderNo,
KSCH,
ShippedDate,
countrycode
FROM ADMIN.BPCS_OTS
WHERE countrycode='US'
and extract(month from shippeddate)=9
and extract(year from shippeddate)=2022
and sbucode='ADS'
GROUP BY SBUCode,
OrderNo,
KSCH,
ShippedDate,
countrycode)
GROUP BY ShippedDate
,KSCH

 

Yous suggestions would be a great help!!

 

Thanks 

Irshad Shaikh

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @gshaikh,

Can you please share some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hello,

 

Please see below We need 4 as an output as oracle output has 4 rows of output Request you to please find below dummy data 

 

Thank you so much for help 

 

 Data
    
OrdernoOrderLineNumberShippeddateScheduleDate
1232414-11-202220211113
2323616-11-202220221115
2323516-11-202220221115
2323716-11-202220221115
2323816-11-202220221115
6556624-11-202220211113
4543723-11-202220221115
4543823-11-202220221115

 

Query in oracle
     
     
SELECT COUNT(ORDERNO) CNT,
SCHEDULEDATE,
ShippedDate
FROM TABLE1
GROUP BY ORDERNO,
SCHEDULEDATE,
ShippedDate

 

Output In Oracle
    
    
CntScheduleDateShippeddate 
114-11-202220211113 
416-11-202220221115 
124-11-202220211113 
223-11-202220221115 

 

Power Bi Output   
   
     
44 Should be output as above Oracle output has 4 rows 
v-shex-msft
Community Support
Community Support

HI @gshaikh,

You can try to use the following measure formal if it helps:

formula =
CALCULATE (
    COUNT ( 'Table'[ORDERNO] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [countrycode] = "US"
            && MONTH ( [shippeddate] ) = 9
            && YEAR ( [shippeddate] ) = 2022
            && [sbucode] = "ADS"
    ),
    VALUES ( 'Table'[KSCH] ),
    VALUES ( 'Table'[shippeddate] )
)

If the above not help, can you please share some dummy data with raw table structure and expected results? They will help us clarify your data structure and scenario and test coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hello,

 

Unfortunatly No I AM not getting expected output above dax was clubing it and showing total value but We need count rows not total Can you please help me Please 

here is the query in sql if I add extra column then my rows count will get incresed so we are not adding extra columns just few which mentioned in below query

 

SELECT COUNT(ORDERNO) CNT,
KSCH,
ShippedDate
FROM ADMIN.BPCS_OTS
GROUP BY ORDERNO,
KSCH,
ShippedDate

 

Thanks & Regards,

Irshad Shaikh

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.