cancel
Showing results for
Did you mean:

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

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
Helper III

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

3 REPLIES 3
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

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Helper III

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

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors