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
fab196
Helper II
Helper II

dax date parameter

hi everyone,

need your help

i have table having two dates column both are important and i want use that

id locack dateship date
1mumbai8/10/20219/10/2021
1guj11/10/202113/10/2021
3mumbai9/10/202113/10/2021
5mumbai11/10/202113/10/2021
5guj11/10/202113/10/2021
6mumbai9/10/202111/10/2021

it will return 

aim is to calculate count of id based on the ack and ship date 

for ex.if user select the date  11/10/2021 then it will return  count of that day group by location 

so count will be 3 overall ..how to i do that using dax

and so how to i create calender table and use the the single date filetr for particuler date using dax

 

please help 

@amitchandak 

@parry2k 

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @fab196 ,

 

According to your description, a separate date column is created without creating a relationship between the tables. The measure created is used to count the number of locs under the selected date.

I did a test reference as follows:

M =
VAR sel_data =
    SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[ack date] = sel_data )

vhenrykmstf_0-1633489369678.png


If the problem is still not resolved, please provide more information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

6 REPLIES 6
v-henryk-mstf
Community Support
Community Support

Hi @fab196 ,

 

The sql code and dax have different calculation logic and cannot be directly converted based on the code you provided.

 

Does the solution given above meet your requirements, if there are still problems, please provide clear information about your requirements and screenshots of the expected results, I will answer you as soon as possible.


Best Regards,
Henry


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

v-henryk-mstf
Community Support
Community Support

Hi @fab196 ,

 

According to your description, a separate date column is created without creating a relationship between the tables. The measure created is used to count the number of locs under the selected date.

I did a test reference as follows:

M =
VAR sel_data =
    SELECTEDVALUE ( 'Calendar'[Date] )
RETURN
    CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[ack date] = sel_data )

vhenrykmstf_0-1633489369678.png


If the problem is still not resolved, please provide more information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

@v-henryk-mstf 

hi ,

it is possible to generate code like sql in dax

here is my sql code

select sum(ship),sum(ack) from (select count(id) as ship,0 as ack from tramsaction where ship date >=date and ship date<=date
union
select 0 as ship , count(id) as ack from tramsaction where ack date>=cast( datefromparts(year(@strdate),month(@strdate),1) as datetime) and ack date<=CONVERT(date, @strdate, 120) )
group by location)a

 

please help

parry2k
Super User
Super User

@fab196 doesn't make sense what you are looking for. why you want the union and set values to zero, it will return two rows, how you will visualize it? What you are trying to do? The answer I provided earlier gives you a count based on the selected date, not sure why you want two rows with 0 values.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@fab196 create a date table following my post here Create a basic Date table in your data model for Time Intelligence calculations | PeryTUS IT Solutio...

 

after the table is added, set the relationship date table on both the dates and one relationship will be inactive.

 

Add following two measures assuming an inactive relationship with a ship date

 

Count = COUNTROWS ( YourTable )

Ship Count = CALCULATE ( [Count], USERELATIONSHIP ( DateTable[Date], YourTable[ShipDate] ) )

 

Use slicer from new date table and it should work.

 

Follow us on LinkedIn

 

Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi sir,

thanks for your valuable reply.your given solution is right but requiremnt is slight different .

please chek below sql code i want to do similar using dax and my date parameter should be dynamic

 

please help i m lot of struggling with this issue 

 

declare @date as date ='2021-9-20'


select count(id) as ship,0 as ack from tramsaction where ship date >=date and ship date<=date
union
select 0 as ship , count(id) as ack from tramsaction where ack date>=cast( datefromparts(year(@strdate),month(@strdate),1) as datetime) and ack date<=CONVERT(date, @strdate, 120) )
group by location

 

@amitchandak 

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.