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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
LeaRupnik
Helper III
Helper III

SQL Statment to DAX

Hello, 

a have sql statment, how to do this in dax.

select
CAST(sum([CPP Real_pro_kol])/1000 as INT) as sum_Real_pro_kol
,[CPP Datum_posnetka] as datum_posnetka
,year([CPP Datum_posnetka]) as leto_posnetka
,month([CPP Datum_posnetka]) as mesec_posnetka
,[CPP Leto] as leto
,[CPP Mesec] as mesec
from
[cisppr].[f CPP Cista prodajna premija] t1
inner join
(
select
max([CPP Datum_posnetka]) as leto_Datum_posnetka
from
[cisppr].[f CPP Cista prodajna premija]
group by
year([CPP Datum_posnetka])
,month([CPP Datum_posnetka])
) as t2 on t1.[CPP Datum_posnetka]= t2.leto_Datum_posnetka
where
[CPP Datum_posnetka] <= '2022-03-28'
--[CPP Datum_posnetka] <= '2020-12-31'
--and [CPP Leto] =2021



group by
year([CPP Datum_posnetka])
,month([CPP Datum_posnetka])
,[CPP Datum_posnetka]
,[CPP Leto]
,[CPP Mesec]
order by
year([CPP Datum_posnetka])
,month([CPP Datum_posnetka])
,[CPP Datum_posnetka]
,[CPP Leto]
,[CPP Mesec]

 

thx

LEa

1 ACCEPTED SOLUTION

Hello

I am adding a description of what I need. I have data entered in the table for each day. I would like to return only for maximum data in each year plus month. That is, for 2020 and January, I would only need data from 31.1.2020

 

thanks

Lea

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @LeaRupnik ,

Could you pls share some sample data ,and what you get final by the sql . Remember to remove confidential data.

 

 

Best Regards

Lucien

Greg_Deckler
Super User
Super User

@LeaRupnik These generally go better if you provide sample data and expected output versus the SQL code. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Hello

I am adding a description of what I need. I have data entered in the table for each day. I would like to return only for maximum data in each year plus month. That is, for 2020 and January, I would only need data from 31.1.2020

 

thanks

Lea

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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