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
Yrstruly2021
Helper V
Helper V

Replicate Excel in to Dax

I am trying to replicate my excel calculations in Powerbi. Sheet 3 in https://drive.google.com/file/d/1c607JpoZPCWXfK9exJaTjGo4kU9oWdyD/view?usp=sharing  and sheet 2 in https://drive.google.com/file/d/1E-k77iw7N58FFqX3lf2CBEDBoGFKUpq_/view?usp=sharing i devide to get desired results. I would like the same in Powerbi.

 

To get the desired tables and column name changes i use this sql code:

 

# App Filter Categories
select a.label as 'App Category'
, b.label as 'Menu'
, c.product_uid as 'Product UID'
from app_menu_filters a
left join app_menu_filters b on b.parent_uid=a.uid
left join app_menu_filter_products c on b.uid=c.app_menu_filter_uid
where a.status='A' and a.level=1
order by 1,2,3;

# Sales and Product Data
SELECT date(o.created_datetime) as Date, od.product_uid as 'Product UID',
p.manufacturer Manufacturer, p.bmc BMC, p.brand Brand, od.label as SKUs, p.selling_unit as 'Unit of Measure',
ROUND(if(od.amended_quantity is not null, od.amended_quantity, od.quantity)) as 'Units Sold',
ROUND((if(od.amended_quantity IS NOT NULL, od.amended_quantity, od.quantity))*p.content,2) as 'Sales Volume',
ROUND((if(od.amended_quantity is not null, od.amended_quantity, od.quantity))*od.price,2) as 'Sales Value'
FROM order_detail od
left join `order` o on od.order_uid=o.uid
left join product p on od.product_uid=p.uid
where o.status in ('D',1,2,3,4,5)
and not od.label ='Plastic Bag'
and date(o.created_datetime) >= '2020-04-01'

 

Problem is, i am not getting these sales data in my powerbi model when using the above sql script, as indicated here: https://drive.google.com/file/d/1E-k77iw7N58FFqX3lf2CBEDBoGFKUpq_/view?usp=sharing

What am i doing wrong?

 

PBIX file with SQL code use https://drive.google.com/file/d/186vsjbqclSXB4m5LGwdp3agMQ6-63LDs/view?usp=sharing 

 

PBIX when i pull in the tables manually :https://drive.google.com/file/d/1HCoYlPrhBQKuvWb-TpOBbDBEnv0BV0Sj/view?usp=sharing 

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

Hi @Yrstruly2021 ,

 

v-lionel-msft_1-1617341519135.png

When you do like the above, the Desktop reports an error, right?
What is the error message? I can not download your .pbix file.

 

v-lionel-msft_3-1617341697360.png

The results of these two SQL queries need to be imported twice. Did you do this?

 

Best regards,
Lionel Chen

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

2 REPLIES 2
v-lionel-msft
Community Support
Community Support

Hi @Yrstruly2021 ,

 

v-lionel-msft_1-1617341519135.png

When you do like the above, the Desktop reports an error, right?
What is the error message? I can not download your .pbix file.

 

v-lionel-msft_3-1617341697360.png

The results of these two SQL queries need to be imported twice. Did you do this?

 

Best regards,
Lionel Chen

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

 

 

Yrstruly2021
Helper V
Helper V

@

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!

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.

Top Solution Authors